]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/commitdiff
Fixes for issue #158
authorPhil Rittenhouse <phil@laurelcreeksystems.com>
Thu, 17 Apr 2025 13:54:31 +0000 (09:54 -0400)
committerPhil Rittenhouse <phil@laurelcreeksystems.com>
Thu, 17 Apr 2025 13:54:31 +0000 (09:54 -0400)
Fixed area union logic
Fixed _shape_set_dirty to add new position area to the dirty area
Use int() to make sure circle radius is an integer

displayio/_area.py
vectorio/_circle.py
vectorio/_vectorshape.py

index f7272dd747bf25ae79ca94987ce278f0914b797a..0b3dd80b8b5a908dcca61630a00732d5a2776b20 100644 (file)
@@ -87,10 +87,10 @@ class Area:
     def union(self, other, union):
         """Combine this area along with another into union"""
         if self.empty():
-            self.copy_into(union)
+            other.copy_into(union)
             return
         if other.empty():
-            other.copy_into(union)
+            self.copy_into(union)
             return
 
         union.x1 = min(self.x1, other.x1)
index cc87351b8a9b5c2af665a271108bd21b8f093eb3..f002800d7c66e627d00c75725c9e772da09e1668 100644 (file)
@@ -61,7 +61,7 @@ class Circle(_VectorShape):
     def radius(self, value: int) -> None:
         if value < 1:
             raise ValueError("radius must be >= 1")
-        self._radius = abs(value)
+        self._radius = int(value) # other code assumes radius is an integer
         self._shape_set_dirty()
 
     @property
index d3d1ddb3012155e1ef49db4e7be36b5b789d2f7d..999f82eed091e10126dac347d42844a16ba1e074 100644 (file)
@@ -122,9 +122,14 @@ class _VectorShape:
         self._get_screen_area(current_area)
         moved = current_area != self._current_area
         if moved:
+            # This will add _current_area (the old position) to dirty area 
             self._current_area.union(
                 self._ephemeral_dirty_area, self._ephemeral_dirty_area
             )
+            # This will add the new position to the dirty area
+            current_area.union(
+                self._ephemeral_dirty_area, self._ephemeral_dirty_area
+            )
             # Dirty area tracks the shape's footprint between draws.  It's reset on refresh finish.
             current_area.copy_into(self._current_area)
         self._current_area_dirty = True