Skip to main content

DynamicScheme

Struct DynamicScheme 

Source
pub struct DynamicScheme {
Show 13 fields pub source_color_hct: Hct, pub source_color_argb: u32, pub variant: Variant, pub contrast_level: f64, pub is_dark: bool, pub platform: Platform, pub spec_version: 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

A dynamic color scheme generated from a source color.

Constructed by a set of values representing the current UI state (such as whether or not it’s dark theme, what the theme style is, etc.), and provides a set of TonalPalettes that can create colors that fit in with the theme style. Used by DynamicColor to resolve into a color.

Fields§

§source_color_hct: Hct

The source color of the theme as an HCT color

§source_color_argb: u32

The source color of the theme as an ARGB 32-bit integer

§variant: Variant

The variant, or style, of the theme

§contrast_level: f64

Value from -1 to 1. -1 represents minimum contrast, 0 represents standard, 1 represents maximum contrast

§is_dark: bool

Whether the scheme is in dark mode or light mode

§platform: Platform

The platform on which this scheme is intended to be used

§spec_version: SpecVersion

The version of the design spec that this scheme is based on

§primary_palette: TonalPalette

Given a tone, produces a color. Hue and chroma of the color are specified in the design specification of the variant. Usually colorful.

§secondary_palette: TonalPalette

Given a tone, produces a color. Hue and chroma of the color are specified in the design specification of the variant. Usually less colorful.

§tertiary_palette: TonalPalette

Given a tone, produces a color. Hue and chroma of the color are specified in the design specification of the variant. Usually a different hue from primary and colorful.

§neutral_palette: TonalPalette

Given a tone, produces a color. Hue and chroma of the color are specified in the design specification of the variant. Usually not colorful at all, intended for background & surface colors.

§neutral_variant_palette: TonalPalette

Given a tone, produces a color. Hue and chroma of the color are specified in the design specification of the variant. Usually not colorful, but slightly more colorful than Neutral. Intended for backgrounds & surfaces.

§error_palette: TonalPalette

Given a tone, produces a reddish, colorful, color.

Implementations§

Source§

impl DynamicScheme

Source

pub fn new(options: DynamicSchemeOptions) -> DynamicScheme

Create a new DynamicScheme from options.

Uses spec-versioned palette generation delegates based on the variant and spec version. The delegate handles variant-specific, platform-aware, and dark/light mode adjustments.

§Arguments
  • options - Configuration for the scheme including source color, variant, contrast level, dark mode, platform, and optional custom palettes.
§Returns

A fully configured DynamicScheme with all palettes generated.

Trait Implementations§

Source§

impl Clone for DynamicScheme

Source§

fn clone(&self) -> DynamicScheme

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.