colors – Predefined color values

Predefined “standard colors” and helper functions.

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

codeair.colors.BLACK = (0, 0, 0)
codeair.colors.BLUE = (0, 0, 255)
codeair.colors.BROWN = (111, 78, 55)
codeair.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)}
codeair.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))
codeair.colors.CYAN = (0, 255, 255)
codeair.colors.DARK_BLUE = (0, 0, 139)
codeair.colors.DARK_GREEN = (34, 139, 34)
codeair.colors.GRAY = (96, 96, 96)
codeair.colors.GREEN = (0, 255, 0)
codeair.colors.LIGHT_GRAY = (211, 211, 211)
codeair.colors.MAGENTA = (255, 0, 255)
codeair.colors.ORANGE = (255, 165, 0)
codeair.colors.PINK = (255, 20, 147)
codeair.colors.PURPLE = (106, 13, 173)
codeair.colors.RED = (255, 0, 0)
codeair.colors.TRANSPARENT = (247, 251, 247)
codeair.colors.WHITE = (255, 255, 255)
codeair.colors.YELLOW = (255, 255, 0)
codeair.colors.color16(color24)[source]

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

codeair.colors.int_to_rgb(h)[source]

Convert integer to RGB tuple

codeair.colors.rgb_to_int(rgb)[source]

Convert RGB tuple to an integer.

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

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

codeair.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