]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_structs.py
More displayio code updates
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _structs.py
index 955b9b4a1a8c803ba66d890bed013b4500379a84..a46fb48204529403ee4e8f8273fdf3396f86ce8a 100644 (file)
@@ -49,7 +49,7 @@ class TransformStruct:
 
 @dataclass
 class ColorspaceStruct:
-    # pylint: disable=invalid-name
+    # pylint: disable=invalid-name, too-many-instance-attributes
     """Colorspace Struct Dataclass"""
     depth: int
     bytes_per_cell: int = 0
@@ -58,7 +58,49 @@ class ColorspaceStruct:
     grayscale_bit: int = 0
     grayscale: bool = False
     tricolor: bool = False
+    sevencolor: bool = False  # Acep e-ink screens.
     pixels_in_byte_share_row: bool = False
     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,
+        )