pub struct DynamicScheme {
pub source: Hct,
pub variant: Variant,
pub contrast_level: f64,
pub is_dark: bool,
pub spec: SpecVersion,
pub primary_palette: TonalPalette,
pub secondary_palette: TonalPalette,
pub tertiary_palette: TonalPalette,
pub neutral_palette: TonalPalette,
pub neutral_variant_palette: TonalPalette,
pub error_palette: TonalPalette,
}Expand description
The state a DynamicRole resolves against.
use gpui_kit_material_color::dynamic::{
DynamicRole, DynamicScheme, Hct, SpecVersion, Variant,
};
let scheme = DynamicScheme::new(
Hct::from_argb(0xff6750a4),
Variant::TonalSpot,
false,
0.0,
SpecVersion::Spec2021,
);
assert_eq!(scheme.argb(DynamicRole::Primary), 0xff65558f);Fields§
§source: HctThe seed.
variant: VariantThe style.
contrast_level: f64-1 is minimum contrast, 0 the design as specified, 0.5 medium, 1 maximum.
is_dark: boolDark mode.
spec: SpecVersionThe spec actually in force, after Variant::has_2025_spec.
primary_palette: TonalPaletteUsually colorful.
secondary_palette: TonalPaletteUsually less colorful.
tertiary_palette: TonalPaletteUsually a different hue from primary.
neutral_palette: TonalPaletteUsually not colorful: surfaces.
neutral_variant_palette: TonalPaletteSlightly more colorful than neutral: outlines and variants.
error_palette: TonalPaletteReddish.
Implementations§
Source§impl DynamicScheme
impl DynamicScheme
Sourcepub fn new(
source: Hct,
variant: Variant,
is_dark: bool,
contrast_level: f64,
spec: SpecVersion,
) -> Self
pub fn new( source: Hct, variant: Variant, is_dark: bool, contrast_level: f64, spec: SpecVersion, ) -> Self
Resolve the palettes of a seed. A non-finite contrast level counts as 0; others are limited to -1..=1.
Sourcepub fn piecewise_hue(source: Hct, breakpoints: &[f64], hues: &[f64]) -> f64
pub fn piecewise_hue(source: Hct, breakpoints: &[f64], hues: &[f64]) -> f64
The hue in hues at the range of breakpoints holding the source’s
hue, or the source’s hue when no range does.
Sourcepub fn rotated_hue(source: Hct, breakpoints: &[f64], rotations: &[f64]) -> f64
pub fn rotated_hue(source: Hct, breakpoints: &[f64], rotations: &[f64]) -> f64
The source’s hue rotated by the entry of rotations at the range of
breakpoints holding it.
Sourcepub fn argb(&self, role: DynamicRole) -> u32
pub fn argb(&self, role: DynamicRole) -> u32
The ARGB color of a role.
Sourcepub fn hct(&self, role: DynamicRole) -> Hct
pub fn hct(&self, role: DynamicRole) -> Hct
The HCT color of a role.
Sourcepub fn tone(&self, role: DynamicRole) -> f64
pub fn tone(&self, role: DynamicRole) -> f64
The tone of a role. This resolves contrast constraints; for the color
use Self::hct.
Trait Implementations§
Source§impl Clone for DynamicScheme
impl Clone for DynamicScheme
Source§fn clone(&self) -> DynamicScheme
fn clone(&self) -> DynamicScheme
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more