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: HslaThe secondary accent: less prominent than primary.
on_secondary: HslaContent on secondary.
secondary_container: Hsla(–secondary)
on_secondary_container: Hsla(–on-secondary)
tertiary: Hsla(–tertiary)
on_tertiary: HslaContent on tertiary.
tertiary_container: Hsla(–tertiary-soft)
on_tertiary_container: Hsla(–on-tertiary-soft)
surface: Hsla(–pane)
surface_dim: HslaThe darkest surface: behind everything, never brighter than surface.
surface_bright: HslaThe brightest surface: never dimmer than surface.
surface_container_lowest: HslaSunk below the other containers (a field inside a card).
surface_container_low: HslaSlightly 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: HslaInverse of surface: snackbars and tooltips.
inverse_on_surface: HslaContent on inverse_surface.
inverse_primary: HslaAn action on inverse_surface (a snackbar’s button).
scrim: HslaDims what is behind a modal.
error: Hsla(–bad)
on_error: HslaContent on error.
error_container: Hsla§on_error_container: Hsla§success: Hsla(–ok)
warning: Hsla(–warn)
shadow: HslaShadow color for menus and FABs.
Implementations§
Source§impl Scheme
impl Scheme
pub fn baseline_light() -> Self
pub fn baseline_dark() -> Self
Sourcepub fn lerp(&self, other: &Scheme, t: f32) -> Scheme
pub fn lerp(&self, other: &Scheme, t: f32) -> Scheme
Every role mixed between self (at t = 0) and other (at t = 1), in sRGB.
Sourcepub fn from_seed(seed: Hsla, dark: bool) -> Self
pub fn from_seed(seed: Hsla, dark: bool) -> Self
Dynamic “tonal spot” scheme (2021 spec) from a seed color.
Sourcepub fn from_seed_variant(
seed: Hsla,
dark: bool,
variant: SchemeVariant,
contrast: f32,
) -> Self
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).
Sourcepub fn derive_roles(self) -> Self
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§
impl Copy for Scheme
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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