colors – Predefined color values

Predefined “standard colors” and helper functions.

Colors are defined as (RED, GREEN, BLUE) tuples. Feel free to define your own!

colors.BLACK = (0, 0, 0)
colors.BLUE = (0, 0, 255)
colors.BROWN = (111, 78, 55)
colors.COLORS_BY_NAME = {'BLACK': (0, 0, 0), 'BLUE': (0, 0, 255), 'BROWN': (111, 78, 55), 'CYAN': (0, 255, 255), 'DARK_BLUE': (0, 0, 139), 'DARK_GREEN': (34, 139, 34), 'GRAY': (96, 96, 96), 'GREEN': (0, 255, 0), 'LIGHT_GRAY': (211, 211, 211), 'MAGENTA': (255, 0, 255), 'ORANGE': (255, 165, 0), 'PINK': (255, 20, 147), 'PURPLE': (106, 13, 173), 'RED': (255, 0, 0), 'TRANSPARENT': (247, 251, 247), 'WHITE': (255, 255, 255), 'YELLOW': (255, 255, 0)}
colors.COLOR_LIST = ((0, 0, 0), (111, 78, 55), (255, 0, 0), (255, 165, 0), (255, 255, 0), (0, 255, 0), (0, 0, 255), (106, 13, 173), (96, 96, 96), (255, 255, 255), (0, 255, 255), (255, 0, 255), (255, 20, 147), (211, 211, 211), (34, 139, 34), (0, 0, 139))
colors.CYAN = (0, 255, 255)
colors.DARK_BLUE = (0, 0, 139)
colors.DARK_GREEN = (34, 139, 34)
colors.GRAY = (96, 96, 96)
colors.GREEN = (0, 255, 0)
colors.LIGHT_GRAY = (211, 211, 211)
colors.MAGENTA = (255, 0, 255)
colors.ORANGE = (255, 165, 0)
colors.PINK = (255, 20, 147)
colors.PURPLE = (106, 13, 173)
colors.RED = (255, 0, 0)
colors.TRANSPARENT = (247, 251, 247)
colors.WHITE = (255, 255, 255)
colors.YELLOW = (255, 255, 0)
colors.color16(color24)[source]

Convert a 24-bit RGB tuple to a 16-bit native LCD color tuple.

colors.int_to_rgb(h)[source]

Convert integer to RGB tuple

colors.rgb_to_int(rgb)[source]

Convert RGB tuple to an integer.

colors.scale_rgb(val, pcnt=100)[source]

Scale RGB tuple elements by given percentage (bright/dim)

colors.to565(r, g, b)[source]

Convert 888 RGB (24 bits) to 565 (16 bits) Note: The CodeX LCD uses 16-bit colors natively!

Download Source