pub struct MaterialColor { /* private fields */ }Expand description
A colour ramp: one hue in numbered steps, from the palest (50) to the darkest
(900), plus the primary step the family is named after.
Accent ramps carry the four steps 100, 200, 400, 700; the grey ramp carries
two extra half-steps (350, 850). That is why the steps are a slice rather than a
fixed array — a ramp states which steps it has, and MaterialColor::shade answers
None for one it does not.
use frus_core::MaterialColor;
assert_eq!(MaterialColor::RED.shade(300), Some(frus_core::Colors::RED_300));
assert_eq!(MaterialColor::RED.shade(350), None); // only grey has the half-steps
assert_eq!(MaterialColor::GREY.shade(350), Some(frus_core::Colors::GREY_350));Implementations§
Source§impl MaterialColor
impl MaterialColor
Sourcepub const fn new(
primary: Color,
shades: &'static [(u16, Color)],
) -> MaterialColor
pub const fn new( primary: Color, shades: &'static [(u16, Color)], ) -> MaterialColor
Builds a ramp from its primary step and its numbered steps, which must be in ascending order.
Sourcepub const fn primary(self) -> Color
pub const fn primary(self) -> Color
The step the family is named after — 500 for a primary ramp, 200 for an accent.
Sourcepub fn shade(self, step: u16) -> Option<Color>
pub fn shade(self, step: u16) -> Option<Color>
The colour at step, or None if this ramp has no such step.
Sourcepub fn shade_or_primary(self, step: u16) -> Color
pub fn shade_or_primary(self, step: u16) -> Color
The colour at step, falling back to the primary if the ramp has no such step.
Source§impl MaterialColor
impl MaterialColor
Sourcepub const RED: MaterialColor
pub const RED: MaterialColor
The red ramp: 10 steps, 50 to 900.
Sourcepub const PINK: MaterialColor
pub const PINK: MaterialColor
The pink ramp: 10 steps, 50 to 900.
Sourcepub const PURPLE: MaterialColor
pub const PURPLE: MaterialColor
The purple ramp: 10 steps, 50 to 900.
Sourcepub const DEEP_PURPLE: MaterialColor
pub const DEEP_PURPLE: MaterialColor
The deep purple ramp: 10 steps, 50 to 900.
Sourcepub const INDIGO: MaterialColor
pub const INDIGO: MaterialColor
The indigo ramp: 10 steps, 50 to 900.
Sourcepub const BLUE: MaterialColor
pub const BLUE: MaterialColor
The blue ramp: 10 steps, 50 to 900.
Sourcepub const LIGHT_BLUE: MaterialColor
pub const LIGHT_BLUE: MaterialColor
The light blue ramp: 10 steps, 50 to 900.
Sourcepub const CYAN: MaterialColor
pub const CYAN: MaterialColor
The cyan ramp: 10 steps, 50 to 900.
Sourcepub const TEAL: MaterialColor
pub const TEAL: MaterialColor
The teal ramp: 10 steps, 50 to 900.
Sourcepub const GREEN: MaterialColor
pub const GREEN: MaterialColor
The green ramp: 10 steps, 50 to 900.
Sourcepub const LIGHT_GREEN: MaterialColor
pub const LIGHT_GREEN: MaterialColor
The light green ramp: 10 steps, 50 to 900.
Sourcepub const LIME: MaterialColor
pub const LIME: MaterialColor
The lime ramp: 10 steps, 50 to 900.
Sourcepub const YELLOW: MaterialColor
pub const YELLOW: MaterialColor
The yellow ramp: 10 steps, 50 to 900.
Sourcepub const AMBER: MaterialColor
pub const AMBER: MaterialColor
The amber ramp: 10 steps, 50 to 900.
Sourcepub const ORANGE: MaterialColor
pub const ORANGE: MaterialColor
The orange ramp: 10 steps, 50 to 900.
Sourcepub const DEEP_ORANGE: MaterialColor
pub const DEEP_ORANGE: MaterialColor
The deep orange ramp: 10 steps, 50 to 900.
Sourcepub const BROWN: MaterialColor
pub const BROWN: MaterialColor
The brown ramp: 10 steps, 50 to 900.
Sourcepub const GREY: MaterialColor
pub const GREY: MaterialColor
The grey ramp: 12 steps, 50 to 900.
Sourcepub const BLUE_GREY: MaterialColor
pub const BLUE_GREY: MaterialColor
The blue grey ramp: 10 steps, 50 to 900.
Sourcepub const RED_ACCENT: MaterialColor
pub const RED_ACCENT: MaterialColor
The red accent ramp: 4 steps, 100 to 700.
Sourcepub const PINK_ACCENT: MaterialColor
pub const PINK_ACCENT: MaterialColor
The pink accent ramp: 4 steps, 100 to 700.
Sourcepub const PURPLE_ACCENT: MaterialColor
pub const PURPLE_ACCENT: MaterialColor
The purple accent ramp: 4 steps, 100 to 700.
Sourcepub const DEEP_PURPLE_ACCENT: MaterialColor
pub const DEEP_PURPLE_ACCENT: MaterialColor
The deep purple accent ramp: 4 steps, 100 to 700.
Sourcepub const INDIGO_ACCENT: MaterialColor
pub const INDIGO_ACCENT: MaterialColor
The indigo accent ramp: 4 steps, 100 to 700.
Sourcepub const BLUE_ACCENT: MaterialColor
pub const BLUE_ACCENT: MaterialColor
The blue accent ramp: 4 steps, 100 to 700.
Sourcepub const LIGHT_BLUE_ACCENT: MaterialColor
pub const LIGHT_BLUE_ACCENT: MaterialColor
The light blue accent ramp: 4 steps, 100 to 700.
Sourcepub const CYAN_ACCENT: MaterialColor
pub const CYAN_ACCENT: MaterialColor
The cyan accent ramp: 4 steps, 100 to 700.
Sourcepub const TEAL_ACCENT: MaterialColor
pub const TEAL_ACCENT: MaterialColor
The teal accent ramp: 4 steps, 100 to 700.
Sourcepub const GREEN_ACCENT: MaterialColor
pub const GREEN_ACCENT: MaterialColor
The green accent ramp: 4 steps, 100 to 700.
Sourcepub const LIGHT_GREEN_ACCENT: MaterialColor
pub const LIGHT_GREEN_ACCENT: MaterialColor
The light green accent ramp: 4 steps, 100 to 700.
Sourcepub const LIME_ACCENT: MaterialColor
pub const LIME_ACCENT: MaterialColor
The lime accent ramp: 4 steps, 100 to 700.
Sourcepub const YELLOW_ACCENT: MaterialColor
pub const YELLOW_ACCENT: MaterialColor
The yellow accent ramp: 4 steps, 100 to 700.
Sourcepub const AMBER_ACCENT: MaterialColor
pub const AMBER_ACCENT: MaterialColor
The amber accent ramp: 4 steps, 100 to 700.
Sourcepub const ORANGE_ACCENT: MaterialColor
pub const ORANGE_ACCENT: MaterialColor
The orange accent ramp: 4 steps, 100 to 700.
Sourcepub const DEEP_ORANGE_ACCENT: MaterialColor
pub const DEEP_ORANGE_ACCENT: MaterialColor
The deep orange accent ramp: 4 steps, 100 to 700.
Trait Implementations§
Source§impl Clone for MaterialColor
impl Clone for MaterialColor
Source§fn clone(&self) -> MaterialColor
fn clone(&self) -> MaterialColor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MaterialColor
Source§impl Debug for MaterialColor
impl Debug for MaterialColor
Source§impl From<MaterialColor> for Color
impl From<MaterialColor> for Color
Source§fn from(ramp: MaterialColor) -> Color
fn from(ramp: MaterialColor) -> Color
A ramp used where a single colour is expected is its primary step.