X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/blobdiff_plain/e6284da03fe940ace9fe15d092f45124cb7c12d2..d11bd79a7202d5a77327cbb65bce9455ec9f8f30:/displayio/_tilegrid.py diff --git a/displayio/_tilegrid.py b/displayio/_tilegrid.py index f2ccde2..f8d47c9 100644 --- a/displayio/_tilegrid.py +++ b/displayio/_tilegrid.py @@ -18,20 +18,17 @@ displayio for Blinka """ 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 @@ -100,9 +97,11 @@ class TileGrid: 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): @@ -296,6 +295,9 @@ class TileGrid: ): 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 @@ -406,3 +408,39 @@ class TileGrid: if not 0 <= value <= 255: raise ValueError("Tile value out of bounds") self._tiles[index] = value + + @property + def width(self): + """Width in tiles""" + return self._width + + @width.setter + def width(self, new_width): + self._width = new_width + + @property + def height(self): + """Height in tiles""" + return self._height + + @height.setter + def height(self, new_height): + self._height = new_height + + @property + def tile_width(self): + """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 + def tile_height(self): + """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