first save
This commit is contained in:
98
app/utils/colors.py
Normal file
98
app/utils/colors.py
Normal file
@@ -0,0 +1,98 @@
|
||||
# colors.py - Color library for LED matrix
|
||||
|
||||
# Basic Colors
|
||||
RED = (255, 0, 0)
|
||||
GREEN = (0, 255, 0)
|
||||
BLUE = (0, 0, 255)
|
||||
|
||||
# Primary Colors
|
||||
YELLOW = (255, 255, 0)
|
||||
MAGENTA = (255, 0, 255)
|
||||
CYAN = (0, 255, 255)
|
||||
|
||||
# White and Black
|
||||
WHITE = (255, 255, 255)
|
||||
BLACK = (0, 0, 0)
|
||||
|
||||
# Grayscale
|
||||
GRAY = (128, 128, 128)
|
||||
LIGHT_GRAY = (192, 192, 192)
|
||||
DARK_GRAY = (64, 64, 64)
|
||||
|
||||
# Warm Colors
|
||||
ORANGE = (255, 165, 0)
|
||||
PINK = (255, 192, 203)
|
||||
HOT_PINK = (255, 105, 180)
|
||||
CORAL = (255, 127, 80)
|
||||
TOMATO = (255, 99, 71)
|
||||
|
||||
# Cool Colors
|
||||
PURPLE = (128, 0, 128)
|
||||
INDIGO = (75, 0, 130)
|
||||
VIOLET = (238, 130, 238)
|
||||
LAVENDER = (230, 230, 250)
|
||||
|
||||
# Earth Tones
|
||||
BROWN = (165, 42, 42)
|
||||
CHOCOLATE = (210, 105, 30)
|
||||
SANDY_BROWN = (244, 164, 96)
|
||||
GOLD = (255, 215, 0)
|
||||
|
||||
# Bright Colors
|
||||
LIME = (0, 255, 0)
|
||||
AQUA = (0, 255, 255)
|
||||
TURQUOISE = (64, 224, 208)
|
||||
SPRING_GREEN = (0, 255, 127)
|
||||
|
||||
# Pastel Colors
|
||||
PASTEL_RED = (255, 128, 128)
|
||||
PASTEL_GREEN = (128, 255, 128)
|
||||
PASTEL_BLUE = (128, 128, 255)
|
||||
PASTEL_YELLOW = (255, 255, 128)
|
||||
PASTEL_PURPLE = (255, 128, 255)
|
||||
PASTEL_CYAN = (128, 255, 255)
|
||||
|
||||
# Neon Colors
|
||||
NEON_RED = (255, 0, 0)
|
||||
NEON_GREEN = (57, 255, 20)
|
||||
NEON_BLUE = (0, 0, 255)
|
||||
NEON_YELLOW = (255, 255, 0)
|
||||
NEON_PINK = (255, 0, 128)
|
||||
NEON_ORANGE = (255, 128, 0)
|
||||
|
||||
# Rainbow Colors (for rainbow effects)
|
||||
RAINBOW = [
|
||||
(255, 0, 0), # Red
|
||||
(255, 127, 0), # Orange
|
||||
(255, 255, 0), # Yellow
|
||||
(0, 255, 0), # Green
|
||||
(0, 0, 255), # Blue
|
||||
(75, 0, 130), # Indigo
|
||||
(148, 0, 211), # Violet
|
||||
]
|
||||
|
||||
# Holiday Colors
|
||||
CHRISTMAS_RED = (255, 0, 0)
|
||||
CHRISTMAS_GREEN = (0, 255, 0)
|
||||
HALLOWEEN_ORANGE = (255, 140, 0)
|
||||
HALLOWEEN_PURPLE = (128, 0, 128)
|
||||
|
||||
|
||||
# Utility function to create custom colors
|
||||
def rgb(r, g, b):
|
||||
"""Create a color from RGB values (0-255)"""
|
||||
return (r, g, b)
|
||||
|
||||
|
||||
def hex_to_rgb(hex_color):
|
||||
"""Convert hex color (#RRGGBB) to RGB tuple"""
|
||||
hex_color = hex_color.lstrip('#')
|
||||
return tuple(int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
|
||||
|
||||
|
||||
def fade_color(color1, color2, factor):
|
||||
"""Fade between two colors (factor 0.0 to 1.0)"""
|
||||
r = int(color1[0] + (color2[0] - color1[0]) * factor)
|
||||
g = int(color1[1] + (color2[1] - color1[1]) * factor)
|
||||
b = int(color1[2] + (color2[2] - color1[2]) * factor)
|
||||
return (r, g, b)
|
||||
Reference in New Issue
Block a user