]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_tilegrid.py
Update to pyproject.toml
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _tilegrid.py
index f8d47c99bf75b153e25d7f7f5792c335b984a8b9..ce1d225d248459245621e5c4dc4e9569b39fac73 100644 (file)
@@ -26,7 +26,7 @@ from ._shape import Shape
 from ._palette import Palette
 from ._structs import RectangleStruct, TransformStruct
 
 from ._palette import Palette
 from ._structs import RectangleStruct, TransformStruct
 
-__version__ = "0.0.0-auto.0"
+__version__ = "0.0.0+auto.0"
 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
 
 
 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
 
 
@@ -381,6 +381,42 @@ class TileGrid:
         """The pixel shader of the tilegrid."""
         return self._pixel_shader
 
         """The pixel shader of the tilegrid."""
         return self._pixel_shader
 
+    @pixel_shader.setter
+    def pixel_shader(self, new_pixel_shader: Union[ColorConverter, Palette]) -> None:
+        if not isinstance(new_pixel_shader, ColorConverter) and not isinstance(
+            new_pixel_shader, Palette
+        ):
+            raise TypeError(
+                "Unsupported Type: new_pixel_shader must be ColorConverter or Palette"
+            )
+
+        self._pixel_shader = new_pixel_shader
+
+    @property
+    def bitmap(self) -> Union[Bitmap, OnDiskBitmap, Shape]:
+        """The Bitmap, OnDiskBitmap, or Shape that is assigned to this TileGrid"""
+        return self._bitmap
+
+    @bitmap.setter
+    def bitmap(self, new_bitmap: Union[Bitmap, OnDiskBitmap, Shape]) -> None:
+
+        if (
+            not isinstance(new_bitmap, Bitmap)
+            and not isinstance(new_bitmap, OnDiskBitmap)
+            and not isinstance(new_bitmap, Shape)
+        ):
+            raise TypeError(
+                "Unsupported Type: new_bitmap must be Bitmap, OnDiskBitmap, or Shape"
+            )
+
+        if (
+            new_bitmap.width != self.bitmap.width
+            or new_bitmap.height != self.bitmap.height
+        ):
+            raise ValueError("New bitmap must be same size as old bitmap")
+
+        self._bitmap = new_bitmap
+
     def _extract_and_check_index(self, index):
         if isinstance(index, (tuple, list)):
             x = index[0]
     def _extract_and_check_index(self, index):
         if isinstance(index, (tuple, list)):
             x = index[0]
@@ -410,37 +446,21 @@ class TileGrid:
         self._tiles[index] = value
 
     @property
         self._tiles[index] = value
 
     @property
-    def width(self):
+    def width(self) -> int:
         """Width in tiles"""
         return self._width
 
         """Width in tiles"""
         return self._width
 
-    @width.setter
-    def width(self, new_width):
-        self._width = new_width
-
     @property
     @property
-    def height(self):
+    def height(self) -> int:
         """Height in tiles"""
         return self._height
 
         """Height in tiles"""
         return self._height
 
-    @height.setter
-    def height(self, new_height):
-        self._height = new_height
-
     @property
     @property
-    def tile_width(self):
+    def tile_width(self) -> int:
         """Width of each tile in pixels"""
         return self._tile_width
 
         """Width of each tile in pixels"""
         return self._tile_width
 
-    @tile_width.setter
-    def tile_width(self, new_tile_width):
-        self._tile_width = new_tile_width
-
     @property
     @property
-    def tile_height(self):
+    def tile_height(self) -> int:
         """Height of each tile in pixels"""
         return self._tile_height
         """Height of each tile in pixels"""
         return self._tile_height
-
-    @tile_height.setter
-    def tile_height(self, new_tile_height):
-        self._tile_height = new_tile_height