Expand description
Common color types and conversions for rendering.
This module provides convenience types and conversion functions that work across multiple render backends.
§Supported formats
| Format | Type | Example |
|---|---|---|
| RGB | (u8,u8,u8) | (255, 0, 128) |
| RGBA | (u8,u8,u8,u8) | (255, 0, 128, 200) |
| Hex | &str | "#ff0080" |
| Named CSS | &str | "red", "transparent" |
§Example
use qrcode_render::colors::hex_to_rgb;
// Works under any feature combination (no renderer backend required).
assert_eq!(hex_to_rgb("#1a1a2e"), Some((0x1a, 0x1a, 0x2e)));
assert_eq!(hex_to_rgb("invalid"), None);Structs§
- Cmyk
Color - A CMYK color with normalized
0.0..=1.0components. - LabColor
- A CIE Lab* color using a D65 white point approximation.
- RgbColor
- An opaque sRGB color.
- Srgba
- A unified sRGBA color type for use across all render backends.
Traits§
- Color
Space - A color space that can convert to and from sRGB.
Functions§
- hex_
to_ rgb - Parses a
#rrggbbor#rrggbbaahex color string into RGB or RGBA bytes. - hex_
to_ rgba - Parses a
#rrggbbor#rrggbbaahex color string into RGBA bytes. - rgb_
to_ css - Converts RGB bytes to a
rgb()CSS function string. - rgb_
to_ hex - Converts RGB bytes to a CSS hex string (e.g.,
"#ff0080"). - rgba_
to_ css - Converts RGBA bytes to a
rgba()CSS function string. - rgba_
to_ hex - Converts RGBA bytes to a CSS hex string (e.g.,
"#ff0080c0").