X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/blobdiff_plain/255ac2d73d09bc445dd3522b3b30f861552ccbe4..0d243252f0fb3a3e200df404884e3cc7d872ee13:/displayio/_structs.py diff --git a/displayio/_structs.py b/displayio/_structs.py index 9a2017e..a46fb48 100644 --- a/displayio/_structs.py +++ b/displayio/_structs.py @@ -63,3 +63,44 @@ class ColorspaceStruct: reverse_pixels_in_byte: bool = False reverse_bytes_in_word: bool = False dither: bool = False + + +@dataclass +class InputPixelStruct: + """InputPixel Struct Dataclass""" + + pixel: int = 0 + x: int = 0 + y: int = 0 + tile: int = 0 + tile_x: int = 0 + tile_y: int = 0 + + +@dataclass +class OutputPixelStruct: + """OutputPixel Struct Dataclass""" + + pixel: int = 0 + opaque: bool = False + + +@dataclass +class ColorStruct: + """Color Struct Dataclass""" + + rgb888: int = 0 + cached_colorspace: ColorspaceStruct = None + cached_color: int = 0 + cached_colorspace_grayscale_bit: int = 0 + cached_colorspace_grayscale: bool = False + transparent: bool = False + + def rgba(self) -> tuple[int, int, int, int]: + """Return the color as a tuple of red, green, blue, alpha""" + return ( + self.rgb888 >> 16, + (self.rgb888 >> 8) & 0xFF, + self.rgb888 & 0xFF, + 0 if self.transparent else 0xFF, + )