jangada.mixin.Colorable.color#
- Colorable.color: str#
Color for visualization and styling.
Canonical HTML hex string (
#RRGGBBformat) for visual representation. Accepts various input formats via matplotlib’s color parsing, including hex strings, RGB tuples, and named colors. Always stored in uppercase hex format.See also
Colorable.color_rgbRead-only RGB tuple property
matplotlib.colors.to_hexUnderlying color conversion function
Notes
Requires matplotlib for color parsing. The canonical uppercase
#RRGGBBformat ensures consistency across the system and compatibility with most graphics APIs and web standards.Use
color_rgbproperty for integer RGB values (0-255) when needed by graphics libraries.Examples
Hex string:
obj.color = '#FF0000' assert obj.color == '#FF0000'
RGB tuple:
obj.color = (1.0, 0.0, 0.0) # Float format assert obj.color == '#FF0000'
Color name:
obj.color = 'red' assert obj.color == '#FF0000'
Case normalization:
obj.color = '#ff0000' assert obj.color == '#FF0000' # Uppercase
Get as RGB tuple:
obj.color = '#FF0000' assert obj.color_rgb == (255, 0, 0)