Skip to main content

MaterialColor

Struct MaterialColor 

Source
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

Source

pub const fn new(primary: Color, shades: &'static [(u16, Color)]) -> Self

Builds a ramp from its primary step and its numbered steps, which must be in ascending order.

Source

pub const fn primary(self) -> Color

The step the family is named after — 500 for a primary ramp, 200 for an accent.

Source

pub fn shade(self, step: u16) -> Option<Color>

The colour at step, or None if this ramp has no such step.

Source

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

pub fn steps(self) -> impl Iterator<Item = (u16, Color)>

Every (step, colour) pair, in ascending order.

Source

pub fn len(self) -> usize

The number of steps in the ramp.

Source

pub fn is_empty(self) -> bool

Whether the ramp has no steps at all — no bundled family is empty.

Source§

impl MaterialColor

Source

pub const RED: MaterialColor

The red ramp: 10 steps, 50 to 900.

Source

pub const PINK: MaterialColor

The pink ramp: 10 steps, 50 to 900.

Source

pub const PURPLE: MaterialColor

The purple ramp: 10 steps, 50 to 900.

Source

pub const DEEP_PURPLE: MaterialColor

The deep purple ramp: 10 steps, 50 to 900.

Source

pub const INDIGO: MaterialColor

The indigo ramp: 10 steps, 50 to 900.

Source

pub const BLUE: MaterialColor

The blue ramp: 10 steps, 50 to 900.

Source

pub const LIGHT_BLUE: MaterialColor

The light blue ramp: 10 steps, 50 to 900.

Source

pub const CYAN: MaterialColor

The cyan ramp: 10 steps, 50 to 900.

Source

pub const TEAL: MaterialColor

The teal ramp: 10 steps, 50 to 900.

Source

pub const GREEN: MaterialColor

The green ramp: 10 steps, 50 to 900.

Source

pub const LIGHT_GREEN: MaterialColor

The light green ramp: 10 steps, 50 to 900.

Source

pub const LIME: MaterialColor

The lime ramp: 10 steps, 50 to 900.

Source

pub const YELLOW: MaterialColor

The yellow ramp: 10 steps, 50 to 900.

Source

pub const AMBER: MaterialColor

The amber ramp: 10 steps, 50 to 900.

Source

pub const ORANGE: MaterialColor

The orange ramp: 10 steps, 50 to 900.

Source

pub const DEEP_ORANGE: MaterialColor

The deep orange ramp: 10 steps, 50 to 900.

Source

pub const BROWN: MaterialColor

The brown ramp: 10 steps, 50 to 900.

Source

pub const GREY: MaterialColor

The grey ramp: 12 steps, 50 to 900.

Source

pub const BLUE_GREY: MaterialColor

The blue grey ramp: 10 steps, 50 to 900.

Source

pub const RED_ACCENT: MaterialColor

The red accent ramp: 4 steps, 100 to 700.

Source

pub const PINK_ACCENT: MaterialColor

The pink accent ramp: 4 steps, 100 to 700.

Source

pub const PURPLE_ACCENT: MaterialColor

The purple accent ramp: 4 steps, 100 to 700.

Source

pub const DEEP_PURPLE_ACCENT: MaterialColor

The deep purple accent ramp: 4 steps, 100 to 700.

Source

pub const INDIGO_ACCENT: MaterialColor

The indigo accent ramp: 4 steps, 100 to 700.

Source

pub const BLUE_ACCENT: MaterialColor

The blue accent ramp: 4 steps, 100 to 700.

Source

pub const LIGHT_BLUE_ACCENT: MaterialColor

The light blue accent ramp: 4 steps, 100 to 700.

Source

pub const CYAN_ACCENT: MaterialColor

The cyan accent ramp: 4 steps, 100 to 700.

Source

pub const TEAL_ACCENT: MaterialColor

The teal accent ramp: 4 steps, 100 to 700.

Source

pub const GREEN_ACCENT: MaterialColor

The green accent ramp: 4 steps, 100 to 700.

Source

pub const LIGHT_GREEN_ACCENT: MaterialColor

The light green accent ramp: 4 steps, 100 to 700.

Source

pub const LIME_ACCENT: MaterialColor

The lime accent ramp: 4 steps, 100 to 700.

Source

pub const YELLOW_ACCENT: MaterialColor

The yellow accent ramp: 4 steps, 100 to 700.

Source

pub const AMBER_ACCENT: MaterialColor

The amber accent ramp: 4 steps, 100 to 700.

Source

pub const ORANGE_ACCENT: MaterialColor

The orange accent ramp: 4 steps, 100 to 700.

Source

pub const DEEP_ORANGE_ACCENT: MaterialColor

The deep orange accent ramp: 4 steps, 100 to 700.

Trait Implementations§

Source§

impl Clone for MaterialColor

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 MaterialColor

Source§

impl Debug for MaterialColor

Source§

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

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

impl From<MaterialColor> for Color

Source§

fn from(ramp: MaterialColor) -> Color

A ramp used where a single colour is expected is its primary step.

Source§

impl PartialEq for MaterialColor

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 MaterialColor

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 = !

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.