"""
from typing import Union, Optional, Tuple
-from recordclass import recordclass
from PIL import Image
from ._bitmap import Bitmap
from ._colorconverter import ColorConverter
from ._ondiskbitmap import OnDiskBitmap
from ._shape import Shape
from ._palette import Palette
+from ._structs import RectangleStruct, TransformStruct
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
-Rectangle = recordclass("Rectangle", "x1 y1 x2 y2")
-Transform = recordclass("Transform", "x y dx dy scale transpose_xy mirror_x mirror_y")
-
class TileGrid:
# pylint: disable=too-many-instance-attributes
self._pixel_width = width * tile_width
self._pixel_height = height * tile_height
self._tiles = (self._width * self._height) * [default_tile]
- self.in_group = False
- self._absolute_transform = Transform(0, 0, 1, 1, 1, False, False, False)
- self._current_area = Rectangle(0, 0, self._pixel_width, self._pixel_height)
+ self._in_group = False
+ self._absolute_transform = TransformStruct(0, 0, 1, 1, 1, False, False, False)
+ self._current_area = RectangleStruct(
+ 0, 0, self._pixel_width, self._pixel_height
+ )
self._moved = False
def _update_transform(self, absolute_transform):
):
buffer.alpha_composite(image, (x, y), source=(source_x, source_y))
+ def _finish_refresh(self):
+ pass
+
@property
def hidden(self) -> bool:
"""True when the TileGrid is hidden. This may be False even
"""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]