The color utilities provide a robust system for working with colors in your game. The framework includes both standalone functions and a powerful Color class that supports various color formats and transformations.
Color Class
The Color class is the primary way to work with colors in dill-pixel:
Predefined Colors
The Color class includes several predefined color constants:
Color Formats
RGB to Hex
Convert RGB values to hexadecimal format:
Hex to RGB
Convert hexadecimal colors to RGB format:
WebGL Format
Convert colors to WebGL-compatible format (0-1 range):
Color Operations
Color Interpolation
Smoothly interpolate between two colors:
Random Colors
Generate random colors:
Common Use Cases
UI Elements
Particle Effects
Dynamic Lighting
Best Practices
Use the Color class for consistent color handling across your game
Leverage color interpolation for smooth transitions
Use toWebGL() when working with WebGL shaders
Store frequently used colors as constants
Use meaningful color names in your code for better readability