Crate material_color_rs

Crate material_color_rs 

Source
Expand description

§Material Color Utilities

Material Design 3 color utilities for Rust, including HCT (Hue/Chroma/Tone), tonal palettes, and dynamic color schemes.

§Quick start

Generate a theme from a seed color and query tokens by name:

use material_color_rs::generate_theme_from_color;

let theme = generate_theme_from_color("#39C5BB")?;
let light = &theme.schemes["light"];
let primary = light.get_argb("primary").unwrap();
assert_ne!(primary, 0);

§Data model

§Feature flags

Re-exports§

pub use hct::Hct;
pub use palettes::TonalPalette;
pub use scheme::DynamicScheme;
pub use scheme::Variant;

Modules§

contrast
Contrast utilities used by dynamic colors.
dynamiccolor
Material dynamic color tokens and helpers.
hct
HCT and CAM16 color science primitives.
palettes
Tonal palettes.
scheme
Dynamic theme schemes.
utils
Internal math and color helpers.

Structs§

MaterialTheme
A generated Material theme.
MaterialThemeJson
Material theme JSON structure, compatible with common Material Theme exports.
SchemeColors
A token map for a single scheme (e.g. "light" or "dark").

Functions§

argb_to_hex
Converts an ARGB integer to an uppercase hex RGB string ("#RRGGBB").
argb_to_rgb
Converts an ARGB integer to an (r, g, b) tuple.
argb_to_rgba
Converts an ARGB integer to an [r, g, b, a] array.
argb_to_rgba_f32
Converts an ARGB integer to an [r, g, b, a] float array (each channel in 0.0..=1.0).
generate_theme_from_color
Generates a Material theme from a seed color.
hex_to_argb
Parses a hex RGB string ("#RRGGBB" or "RRGGBB") into an opaque ARGB color (0xFFRRGGBB).