Expand description
Color utilities for the Tessera UI framework.
This module provides the Color
struct and related utilities for working with colors
in the linear sRGB color space. The color representation is optimized for GPU rendering
and shader compatibility.
§Color Space
All colors are represented in the linear sRGB color space, which is the standard for modern graphics rendering. This ensures consistent color reproduction across different devices and platforms.
§Usage
use tessera_ui::Color;
// Create colors using predefined constants
let red = Color::RED;
let transparent = Color::TRANSPARENT;
// Create colors from f32 values (0.0 to 1.0)
let custom_color = Color::new(0.5, 0.3, 0.8, 1.0);
let opaque_color = Color::from_rgb(0.2, 0.7, 0.4);
// Create colors from u8 values (0 to 255)
let from_bytes = Color::from_rgba_u8(128, 64, 192, 255);
let from_rgb_bytes = Color::from_rgb_u8(100, 150, 200);
// Convert from arrays
let from_array: Color = [0.1, 0.2, 0.3, 0.4].into();
let to_array: [f32; 4] = custom_color.into();
Structs§
- Color
- A color in the linear sRGB color space with an alpha component.