Skip to main content

Scheme

Struct Scheme 

Source
pub struct Scheme {
Show 35 fields pub primary: Hsla, pub on_primary: Hsla, pub primary_container: Hsla, pub on_primary_container: Hsla, pub secondary: Hsla, pub on_secondary: Hsla, pub secondary_container: Hsla, pub on_secondary_container: Hsla, pub tertiary: Hsla, pub on_tertiary: Hsla, pub tertiary_container: Hsla, pub on_tertiary_container: Hsla, pub surface: Hsla, pub surface_dim: Hsla, pub surface_bright: Hsla, pub surface_container_lowest: Hsla, pub surface_container_low: Hsla, pub surface_container: Hsla, pub surface_container_high: Hsla, pub surface_container_highest: Hsla, pub on_surface: Hsla, pub on_surface_variant: Hsla, pub outline: Hsla, pub outline_variant: Hsla, pub inverse_surface: Hsla, pub inverse_on_surface: Hsla, pub inverse_primary: Hsla, pub scrim: Hsla, pub error: Hsla, pub on_error: Hsla, pub error_container: Hsla, pub on_error_container: Hsla, pub success: Hsla, pub warning: Hsla, pub shadow: Hsla,
}
Expand description

M3 color roles. Names follow the spec; the reference design’s CSS token is in parentheses.

Fields§

§primary: Hsla

(–accent)

§on_primary: Hsla

(–on-accent)

§primary_container: Hsla

(–accent-soft)

§on_primary_container: Hsla

(–on-accent-soft)

§secondary: Hsla

The secondary accent: less prominent than primary.

§on_secondary: Hsla

Content on secondary.

§secondary_container: Hsla

(–secondary)

§on_secondary_container: Hsla

(–on-secondary)

§tertiary: Hsla

(–tertiary)

§on_tertiary: Hsla

Content on tertiary.

§tertiary_container: Hsla

(–tertiary-soft)

§on_tertiary_container: Hsla

(–on-tertiary-soft)

§surface: Hsla

(–pane)

§surface_dim: Hsla

The darkest surface: behind everything, never brighter than surface.

§surface_bright: Hsla

The brightest surface: never dimmer than surface.

§surface_container_lowest: Hsla

Sunk below the other containers (a field inside a card).

§surface_container_low: Hsla

Slightly above surface.

§surface_container: Hsla

(–bg, –raised)

§surface_container_high: Hsla

(–control, –hover)

§surface_container_highest: Hsla

(–control-2)

§on_surface: Hsla

(–text)

§on_surface_variant: Hsla

(–muted)

§outline: Hsla

(–outline, –faint)

§outline_variant: Hsla

(–border)

§inverse_surface: Hsla

Inverse of surface: snackbars and tooltips.

§inverse_on_surface: Hsla

Content on inverse_surface.

§inverse_primary: Hsla

An action on inverse_surface (a snackbar’s button).

§scrim: Hsla

Dims what is behind a modal.

§error: Hsla

(–bad)

§on_error: Hsla

Content on error.

§error_container: Hsla§on_error_container: Hsla§success: Hsla

(–ok)

§warning: Hsla

(–warn)

§shadow: Hsla

Shadow color for menus and FABs.

Implementations§

Source§

impl Scheme

Source

pub fn baseline_light() -> Self

Source

pub fn baseline_dark() -> Self

Source

pub fn lerp(&self, other: &Scheme, t: f32) -> Scheme

Every role mixed between self (at t = 0) and other (at t = 1), in sRGB.

Source

pub fn from_seed(seed: Hsla, dark: bool) -> Self

Dynamic “tonal spot” scheme (2021 spec) from a seed color.

Source

pub fn from_seed_variant( seed: Hsla, dark: bool, variant: SchemeVariant, contrast: f32, ) -> Self

A dynamic scheme from a seed color in one of the nine Material variants. contrast goes from -1 (least) through 0 (the standard design) to 1 (most, for readability).

Source

pub fn derive_roles(self) -> Self

Fills the roles a hand-made scheme has no color for from the ones it has: the secondary and inverse roles, the on_* of each accent, the dim, bright, low and lowest surfaces and the scrim. They are approximations that follow the scheme’s own polarity; a generated scheme (Scheme::from_seed_variant) already has the exact ones.

ⓘ
Scheme { primary, on_primary, /* your tokens */ ..Scheme::baseline_dark() }.derive_roles()

Trait Implementations§

Source§

impl Clone for Scheme

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Scheme

Source§

impl Debug for Scheme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Scheme

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Scheme

Auto Trait Implementations§

§

impl Forget for Scheme

§

impl Freeze for Scheme

§

impl Move for Scheme

§

impl RefUnwindSafe for Scheme

§

impl Send for Scheme

§

impl Sync for Scheme

§

impl Unpin for Scheme

§

impl UnsafeUnpin for Scheme

§

impl UnwindSafe for Scheme

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more