Expand description
§Material Color Utilities
Rust port of Google’s Material Color Utilities library for generating dynamic color schemes based on Material Design 3.
§Quick Start
use mcu_material_color::prelude::*;
// Create a scheme from a seed color
let seed_color = 0xFF6750A4; // Purple
let hct = Hct::from_int(seed_color);
let scheme = SchemeTonalSpot::new(hct, false, 0.0);
// Access the underlying DynamicScheme through Deref
assert!(!scheme.is_dark);
let _primary = &scheme.primary_palette;§Modules
hct- HCT color space (Hue, Chroma, Tone) based on CAM16palettes- Tonal and core color palette generationscheme- Pre-built color scheme variantsdynamiccolor- Dynamic color system with runtime resolutionblend- Color blending in HCT and CAM16-UCS spacescontrast- WCAG accessibility contrast calculationsquantize- Image color quantization algorithmsscore- Color ranking for theme suitabilitydislike- Fixing unfavorable colorstemperature- Color temperature calculations
§Prelude
For most use cases, import the prelude module:
use mcu_material_color::prelude::*;This provides commonly used types without polluting your namespace.
Re-exports§
pub use mcu_blend as blend;pub use mcu_contrast as contrast;pub use mcu_dislike as dislike;pub use mcu_dynamiccolor as dynamiccolor;pub use mcu_hct as hct;pub use mcu_palettes as palettes;pub use mcu_quantize as quantize;pub use mcu_scheme as scheme;pub use mcu_score as score;pub use mcu_temperature as temperature;pub use mcu_utils as utils;
Modules§
- prelude
- Prelude module providing commonly used types.
Structs§
- Blend
- Color blending operations for combining colors in perceptually uniform spaces.
- Cam16
- CAM16, a color appearance model.
- Color
Spec Delegate Impl2021 - Implementation of the 2021 Material Design 3 color specification.
- Color
Spec Delegate Impl2025 - A delegate for the dynamic color spec of a DynamicScheme in the 2025 spec.
- Contrast
- Utility struct for contrast ratio calculations.
- Contrast
Curve - A contrast curve for dynamic color selection.
- Core
Palette - An intermediate concept between the key color for a UI theme, and a full color scheme.
- Core
Palette Colors - Color definitions for creating a CorePalette from multiple source colors.
- Dynamic
Color - A color that adjusts itself based on UI state provided by DynamicScheme.
- Dynamic
Scheme - A dynamic color scheme generated from a source color.
- Dynamic
Scheme Options - Options for creating a DynamicScheme.
- Hct
- HCT, hue, chroma, and tone.
- Material
Dynamic Colors - DynamicColors for the colors in the Material Design system.
- Quantizer
Celebi - Celebi’s color quantization algorithm implementation.
- Quantizer
Map - Quantizes an image into a map of ARGB colors to their occurrence counts.
- Quantizer
Wsmeans - Weighted squared-means color quantization algorithm.
- Quantizer
Wu - Wu’s color quantization algorithm implementation.
- Scheme
Content - A content-based color scheme that extracts dominant colors from images.
- Scheme
Expressive - An expressive color scheme with creative color manipulation.
- Scheme
Fidelity - A fidelity color scheme that closely follows the source color’s hue and chroma.
- Scheme
Fruit Salad - A fruit salad color scheme with playful hue variations.
- Scheme
Monochrome - A monochromatic color scheme using only lightness and saturation variations.
- Scheme
Neutral - A neutral color scheme with subtle color shifts.
- Scheme
Rainbow - A rainbow color scheme creating a spectrum-inspired color palette.
- Scheme
Tonal Spot - A tonal spot color scheme emphasizing the source color with tonal adjustments.
- Scheme
Vibrant - A vibrant color scheme with saturated, bold colors.
- Score
- Color scoring for ranking colors by theme suitability.
- Score
Options - Options for customizing color scoring behavior.
- Tonal
Palette - A convenience class for retrieving colors that are constant in hue and chroma, but vary in tone.
- Tone
Delta Pair - Documents a constraint between two DynamicColors, in which their tones must have a certain distance from each other.
- Viewing
Conditions - Viewing conditions for the CAM16 color appearance model.
Enums§
- Delta
Constraint - Describes how to fulfill a tone delta pair constraint.
- Platform
- Platform identifier for dynamic scheme. Only used in the 2025 spec.
- Spec
Version - Specification version for dynamic scheme.
- Tone
Polarity - Describes the different in tone between colors.
- Variant
- Enumeration of dynamic color scheme variants for Material Design 3.
Traits§
- Color
Spec Delegate - A delegate that provides the dynamic color constraints for MaterialDynamicColors.