pub struct Palette {Show 22 fields
pub name: &'static str,
pub text_light: Color,
pub text_bright: Color,
pub text_dark: Color,
pub text_black: Color,
pub white: [Color; 8],
pub black: [Color; 8],
pub gray: [Color; 8],
pub red: [Color; 8],
pub orange: [Color; 8],
pub yellow: [Color; 8],
pub limegreen: [Color; 8],
pub green: [Color; 8],
pub bluegreen: [Color; 8],
pub cyan: [Color; 8],
pub blue: [Color; 8],
pub deepblue: [Color; 8],
pub purple: [Color; 8],
pub magenta: [Color; 8],
pub redpink: [Color; 8],
pub primary: [Color; 8],
pub secondary: [Color; 8],
}Expand description
Color palette.
This provides the palette used for a theme.
The ideas packed in here are
- provide two colors for highlighting and accents.
- I always want some white, black and gray.
- I don’t want to miss out anything, so go once round the hue in HSV. Take steps of 30° then we hit pretty much anything interesting.
- Just one variant of each color is not enough, make it 4.
- Background colors need extra considerations. Extend to 8.
Fields§
§name: &'static str§text_light: Color§text_bright: Color§text_dark: Color§text_black: Color§white: [Color; 8]§black: [Color; 8]§gray: [Color; 8]§red: [Color; 8]§orange: [Color; 8]§yellow: [Color; 8]§limegreen: [Color; 8]§green: [Color; 8]§bluegreen: [Color; 8]§cyan: [Color; 8]§blue: [Color; 8]§deepblue: [Color; 8]§purple: [Color; 8]§magenta: [Color; 8]§redpink: [Color; 8]§primary: [Color; 8]§secondary: [Color; 8]Implementations§
Source§impl Palette
impl Palette
Sourcepub const C0: usize = 0usize
pub const C0: usize = 0usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const C1: usize = 1usize
pub const C1: usize = 1usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const C2: usize = 2usize
pub const C2: usize = 2usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const C3: usize = 3usize
pub const C3: usize = 3usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const D0: usize = 4usize
pub const D0: usize = 4usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub const D1: usize = 5usize
pub const D1: usize = 5usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub const D2: usize = 6usize
pub const D2: usize = 6usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub const D3: usize = 7usize
pub const D3: usize = 7usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub fn limegreen(&self, n: usize) -> Style
pub fn limegreen(&self, n: usize) -> Style
Create a style from the given limegreen shade.
n is 0..=3
Sourcepub fn bluegreen(&self, n: usize) -> Style
pub fn bluegreen(&self, n: usize) -> Style
Create a style from the given bluegreen shade.
n is 0..=3
Sourcepub fn deepblue(&self, n: usize) -> Style
pub fn deepblue(&self, n: usize) -> Style
Create a style from the given deepblue shade.
n is 0..=3
Sourcepub fn magenta(&self, n: usize) -> Style
pub fn magenta(&self, n: usize) -> Style
Create a style from the given magenta shade.
n is 0..=3
Sourcepub fn redpink(&self, n: usize) -> Style
pub fn redpink(&self, n: usize) -> Style
Create a style from the given redpink shade.
n is 0..=3
Sourcepub fn fg_white(&self, n: usize) -> Style
pub fn fg_white(&self, n: usize) -> Style
Create a style from the given white shade.
n is 0..=3
Sourcepub fn fg_black(&self, n: usize) -> Style
pub fn fg_black(&self, n: usize) -> Style
Create a style from the given black shade.
n is 0..=3
Sourcepub fn fg_orange(&self, n: usize) -> Style
pub fn fg_orange(&self, n: usize) -> Style
Create a style from the given orange shade.
n is 0..=3
Sourcepub fn fg_yellow(&self, n: usize) -> Style
pub fn fg_yellow(&self, n: usize) -> Style
Create a style from the given yellow shade.
n is 0..=3
Sourcepub fn fg_limegreen(&self, n: usize) -> Style
pub fn fg_limegreen(&self, n: usize) -> Style
Create a style from the given limegreen shade.
n is 0..=3
Sourcepub fn fg_green(&self, n: usize) -> Style
pub fn fg_green(&self, n: usize) -> Style
Create a style from the given green shade.
n is 0..=3
Sourcepub fn fg_bluegreen(&self, n: usize) -> Style
pub fn fg_bluegreen(&self, n: usize) -> Style
Create a style from the given bluegreen shade.
n is 0..=3
Sourcepub fn fg_deepblue(&self, n: usize) -> Style
pub fn fg_deepblue(&self, n: usize) -> Style
Create a style from the given deepblue shade.
n is 0..=3
Sourcepub fn fg_purple(&self, n: usize) -> Style
pub fn fg_purple(&self, n: usize) -> Style
Create a style from the given purple shade.
n is 0..=3
Sourcepub fn fg_magenta(&self, n: usize) -> Style
pub fn fg_magenta(&self, n: usize) -> Style
Create a style from the given magenta shade.
n is 0..=3
Sourcepub fn fg_redpink(&self, n: usize) -> Style
pub fn fg_redpink(&self, n: usize) -> Style
Create a style from the given redpink shade.
n is 0..=3
Sourcepub fn primary(&self, n: usize) -> Style
pub fn primary(&self, n: usize) -> Style
Create a style from the given primary shade.
n is 0..=3
Sourcepub fn secondary(&self, n: usize) -> Style
pub fn secondary(&self, n: usize) -> Style
Create a style from the given secondary shade.
n is 0..=3
Sourcepub fn bg_white(&self, n: usize) -> Style
pub fn bg_white(&self, n: usize) -> Style
Create a style from the given white shade.
n is 0..=3
Sourcepub fn bg_black(&self, n: usize) -> Style
pub fn bg_black(&self, n: usize) -> Style
Create a style from the given black shade.
n is 0..=3
Sourcepub fn bg_orange(&self, n: usize) -> Style
pub fn bg_orange(&self, n: usize) -> Style
Create a style from the given orange shade.
n is 0..=3
Sourcepub fn bg_yellow(&self, n: usize) -> Style
pub fn bg_yellow(&self, n: usize) -> Style
Create a style from the given yellow shade.
n is 0..=3
Sourcepub fn bg_limegreen(&self, n: usize) -> Style
pub fn bg_limegreen(&self, n: usize) -> Style
Create a style from the given limegreen shade.
n is 0..=3
Sourcepub fn bg_green(&self, n: usize) -> Style
pub fn bg_green(&self, n: usize) -> Style
Create a style from the given green shade.
n is 0..=3
Sourcepub fn bg_bluegreen(&self, n: usize) -> Style
pub fn bg_bluegreen(&self, n: usize) -> Style
Create a style from the given bluegreen shade.
n is 0..=3
Sourcepub fn bg_deepblue(&self, n: usize) -> Style
pub fn bg_deepblue(&self, n: usize) -> Style
Create a style from the given deepblue shade.
n is 0..=3
Sourcepub fn bg_purple(&self, n: usize) -> Style
pub fn bg_purple(&self, n: usize) -> Style
Create a style from the given purple shade.
n is 0..=3
Sourcepub fn bg_magenta(&self, n: usize) -> Style
pub fn bg_magenta(&self, n: usize) -> Style
Create a style from the given magenta shade.
n is 0..=3
Sourcepub fn bg_redpink(&self, n: usize) -> Style
pub fn bg_redpink(&self, n: usize) -> Style
Create a style from the given redpink shade.
n is 0..=3
Sourcepub fn bg_primary(&self, n: usize) -> Style
pub fn bg_primary(&self, n: usize) -> Style
Create a style from the given primary shade.
n is 0..=3
Sourcepub fn bg_secondary(&self, n: usize) -> Style
pub fn bg_secondary(&self, n: usize) -> Style
Create a style from the given secondary shade.
n is 0..=3
pub fn text_light(&self) -> Style
pub fn text_bright(&self) -> Style
pub fn text_dark(&self) -> Style
pub fn text_black(&self) -> Style
Source§impl Palette
impl Palette
Sourcepub fn high_contrast(&self, color: Color) -> Style
pub fn high_contrast(&self, color: Color) -> Style
Create a style with the given background color.
Uses white[3] or black[0] for the foreground,
based on rate_text_color.
Sourcepub fn normal_contrast(&self, color: Color) -> Style
pub fn normal_contrast(&self, color: Color) -> Style
Create a style with the given background color.
Uses text_light or text_dark for the foreground,
based on rate_text_color.
Sourcepub fn normal_contrast_color(&self, bg: Color, text: &[Color]) -> Style
pub fn normal_contrast_color(&self, bg: Color, text: &[Color]) -> Style
Pick a color from the choice with a good contrast to the given background.
Sourcepub fn high_contrast_color(&self, bg: Color, text: &[Color]) -> Style
pub fn high_contrast_color(&self, bg: Color, text: &[Color]) -> Style
Pick a color from the choice with the best contrast to the given background.
Sourcepub const fn darken(color: Color, scale_to: u8) -> Color
pub const fn darken(color: Color, scale_to: u8) -> Color
Reduces the range of the given color from 0..255 to 0..scale_to.
This gives a true dark equivalent which can be used as a background for a dark theme.
Sourcepub const fn grayscale(color: Color) -> Color
pub const fn grayscale(color: Color) -> Color
Converts the given color to an equivalent grayscale.
Trait Implementations§
impl Copy for Palette
Auto Trait Implementations§
impl Freeze for Palette
impl RefUnwindSafe for Palette
impl Send for Palette
impl Sync for Palette
impl Unpin for Palette
impl UnwindSafe for Palette
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more