Skip to main content

Module colors

Module colors 

Source
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

FormatTypeExample
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§

CmykColor
A CMYK color with normalized 0.0..=1.0 components.
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§

ColorSpace
A color space that can convert to and from sRGB.

Functions§

hex_to_rgb
Parses a #rrggbb or #rrggbbaa hex color string into RGB or RGBA bytes.
hex_to_rgba
Parses a #rrggbb or #rrggbbaa hex 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").