1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams
 
   3 # SPDX-License-Identifier: MIT
 
   7 ================================================================================
 
   9 Struct Data Classes for Blinka Displayio
 
  11 **Software and Dependencies:**
 
  14   https://github.com/adafruit/Adafruit_Blinka/releases
 
  16 * Author(s): Melissa LeBlanc-Williams
 
  20 from dataclasses import dataclass
 
  22 __version__ = "0.0.0+auto.0"
 
  23 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_Displayio.git"
 
  27 class TransformStruct:
 
  28     # pylint: disable=invalid-name
 
  29     """Transform Struct Dataclass"""
 
  37     mirror_x: bool = False
 
  38     mirror_y: bool = False
 
  39     transpose_xy: bool = False
 
  43 class ColorspaceStruct:
 
  44     # pylint: disable=invalid-name, too-many-instance-attributes
 
  45     """Colorspace Struct Dataclass"""
 
  47     bytes_per_cell: int = 0
 
  49     tricolor_luma: int = 0
 
  50     grayscale_bit: int = 0
 
  51     grayscale: bool = False
 
  52     tricolor: bool = False
 
  53     sevencolor: bool = False  # Acep e-ink screens.
 
  54     pixels_in_byte_share_row: bool = False
 
  55     reverse_pixels_in_byte: bool = False
 
  56     reverse_bytes_in_word: bool = False
 
  61 class InputPixelStruct:
 
  62     """InputPixel Struct Dataclass"""
 
  73 class OutputPixelStruct:
 
  74     """OutputPixel Struct Dataclass"""
 
  82     """Color Struct Dataclass"""
 
  85     cached_colorspace: ColorspaceStruct = None
 
  87     cached_colorspace_grayscale_bit: int = 0
 
  88     cached_colorspace_grayscale: bool = False
 
  89     transparent: bool = False
 
  91     def rgba(self) -> tuple[int, int, int, int]:
 
  92         """Return the color as a tuple of red, green, blue, alpha"""
 
  95             (self.rgb888 >> 8) & 0xFF,
 
  97             0 if self.transparent else 0xFF,
 
 101 null_transform = TransformStruct()  # Use defaults