]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/commitdiff
Merge pull request #162 from FoamyGuy/bitmaptools 2.2.0
authorfoamyguy <foamyguy@gmail.com>
Mon, 5 May 2025 23:28:14 +0000 (18:28 -0500)
committerGitHub <noreply@github.com>
Mon, 5 May 2025 23:28:14 +0000 (18:28 -0500)
add bitmaptools module

README.rst
displayio/_area.py
vectorio/_circle.py
vectorio/_polygon.py
vectorio/_rectangle.py
vectorio/_vectorshape.py

index 8007209389cfddadcb216269d7d828911fbc61e0..4338cae5666ac6089b6066d699286dd5ac2e43fe 100644 (file)
@@ -58,6 +58,8 @@ Contributions are welcome! Please read our `Code of Conduct
 <https://github.com/adafruit/Adafruit_blinka_CircuitPython_displayio/blob/master/CODE_OF_CONDUCT.md>`_
 before contributing to help this project stay welcoming.
 
+To make sure your pull request will pass the commit checks, use pre-commit to check your code formatting. Please see the guide page here for more details: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/check-your-code
+
 Documentation
 =============
 
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..339b1540ff31c08e0e4b94db8eab47d831c5c16b 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 4e6e4449818b8e83536b4ae92ee266650c0beeff..7f2af587465c47b20b7352ad1880a3f54d15934d 100644 (file)
@@ -17,7 +17,7 @@ vectorio Polygon for Blinka
 
 """
 
-from typing import Union, Tuple
+from typing import Union, Tuple, List
 from displayio._colorconverter import ColorConverter
 from displayio._palette import Palette
 from displayio._area import Area
@@ -34,7 +34,7 @@ class Polygon(_VectorShape):
         self,
         *,
         pixel_shader: Union[ColorConverter, Palette],
-        points: list | Tuple[int, int],
+        points: List[Tuple[int, int]],
         x: int,
         y: int,
     ):
@@ -54,12 +54,12 @@ class Polygon(_VectorShape):
         self.points = points
 
     @property
-    def points(self) -> list | Tuple[int, int]:
+    def points(self) -> List[Tuple[int, int]]:
         """The points of the polygon in pixels"""
         return self._points
 
     @points.setter
-    def points(self, value: list | Tuple[int, int]) -> None:
+    def points(self, value: List[Tuple[int, int]]) -> None:
         if len(value) < 3:
             raise ValueError("Polygon needs at least 3 points")
         self._points = value
index e4c595272ad921a577e3ee557c3d8d81e162066f..15880c659c6b6c083c31818d5c77e56367454e85 100644 (file)
@@ -38,6 +38,7 @@ class Rectangle(_VectorShape):
         height: int,
         x: int,
         y: int,
+        color_index: int = 0,
     ):
         """Represents a rectangle by defining its bounds
 
@@ -51,7 +52,7 @@ class Rectangle(_VectorShape):
         """
         self._width = 1
         self._height = 1
-        self._color_index = 1
+        self._color_index = color_index + 1
 
         super().__init__(pixel_shader, x, y)
         self.width = width
index d3d1ddb3012155e1ef49db4e7be36b5b789d2f7d..735e5ae501a4b3863bd78be485c625b9bb01660b 100644 (file)
@@ -122,9 +122,12 @@ 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