pub struct Palette {
pub name: Cow<'static, str>,
pub color: [[Color; 8]; 19],
pub aliased: Cow<'static, [(Cow<'static, str>, ColorIdx)]>,
}Expand description
Color palette.
This provides the palette used for a theme.
Fields§
§name: Cow<'static, str>Name of the color palette.
color: [[Color; 8]; 19]Color palette. Use Colors for indexing.
aliased: Cow<'static, [(Cow<'static, str>, ColorIdx)]>Sorted list of aliases. Must be pre-sorted for binary-search.
Implementations§
Source§impl Palette
impl Palette
Sourcepub fn white(&self, n: usize) -> Style
pub fn white(&self, n: usize) -> Style
Create a style from the given white shade. n is 0..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn black(&self, n: usize) -> Style
pub fn black(&self, n: usize) -> Style
Create a style from the given black shade. n is 0..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn gray(&self, n: usize) -> Style
pub fn gray(&self, n: usize) -> Style
Create a style from the given gray shade. n is 0..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn red(&self, n: usize) -> Style
pub fn red(&self, n: usize) -> Style
Create a style from the given red shade. n is 0..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn orange(&self, n: usize) -> Style
pub fn orange(&self, n: usize) -> Style
Create a style from the given orange shade. n is 0..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn yellow(&self, n: usize) -> Style
pub fn yellow(&self, n: usize) -> Style
Create a style from the given yellow shade. n is 0..=7 with 4..=7 as darker variants of the first 3.
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..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn green(&self, n: usize) -> Style
pub fn green(&self, n: usize) -> Style
Create a style from the given green shade. n is 0..=7 with 4..=7 as darker variants of the first 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..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn cyan(&self, n: usize) -> Style
pub fn cyan(&self, n: usize) -> Style
Create a style from the given cyan shade. n is 0..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn blue(&self, n: usize) -> Style
pub fn blue(&self, n: usize) -> Style
Create a style from the given blue shade. n is 0..=7 with 4..=7 as darker variants of the first 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..=7 with 4..=7 as darker variants of the first 3.
Sourcepub fn purple(&self, n: usize) -> Style
pub fn purple(&self, n: usize) -> Style
Create a style from the given purple shade. n is 0..=7 with 4..=7 as darker variants of the first 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..=7 with 4..=7 as darker variants of the first 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..=7 with 4..=7 as darker variants of the first 3.
Source§impl Palette
impl Palette
Sourcepub fn style(&self, id: Colors, n: usize) -> Style
pub fn style(&self, id: Colors, n: usize) -> Style
Create a style with the given background color. The foreground is chosen from the text-colors for a normal contrast.
Sourcepub fn high_style(&self, id: Colors, n: usize) -> Style
pub fn high_style(&self, id: Colors, n: usize) -> Style
Create a style with the given background color. The foreground is chosen from the text-colors for high contrast.
Sourcepub fn fg_bg_style(&self, fg: Colors, n: usize, bg: Colors, m: usize) -> Style
pub fn fg_bg_style(&self, fg: Colors, n: usize, bg: Colors, m: usize) -> Style
Create a style with the given fg/bg.
Sourcepub fn add_aliased(&mut self, id: &str, color_idx: ColorIdx)
pub fn add_aliased(&mut self, id: &str, color_idx: ColorIdx)
Add an alias.
Sourcepub fn try_aliased(&self, id: &str) -> Option<ColorIdx>
pub fn try_aliased(&self, id: &str) -> Option<ColorIdx>
Try to find an alias.
Sourcepub fn aliased(&self, id: &str) -> ColorIdx
pub fn aliased(&self, id: &str) -> ColorIdx
Get the ColorIdx of an aliased color.
Panic
With debug_assertions this panics if the alias is not found. Otherwise, it returns a default.
Sourcepub fn color_alias(&self, id: &str) -> Color
pub fn color_alias(&self, id: &str) -> Color
Get an aliased color.
Sourcepub fn style_alias(&self, bg: &str) -> Style
pub fn style_alias(&self, bg: &str) -> Style
Get a Style for a color-alias. Uses the color as bg() and finds the matching text-color for normal contrast.
Sourcepub fn high_style_alias(&self, bg: &str) -> Style
pub fn high_style_alias(&self, bg: &str) -> Style
Get a Style for a color-alias. Uses the color as bg() and finds the matching text-color for high contrast.
Sourcepub fn fg_bg_style_alias(&self, fg: &str, bg: &str) -> Style
pub fn fg_bg_style_alias(&self, fg: &str, bg: &str) -> Style
Get a Style for a color-alias. Uses explicit aliases for fg() and bg()
Sourcepub fn fg_style_alias(&self, fg: &str) -> Style
pub fn fg_style_alias(&self, fg: &str) -> Style
Get a Style for a color-alias. This creates a style with only the fg() color set.
Sourcepub fn bg_style_alias(&self, bg: &str) -> Style
pub fn bg_style_alias(&self, bg: &str) -> Style
Get a Style for a color-alias. This creates a style with only the bg() color set.
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 grayscale(color: Color) -> Color
pub const fn grayscale(color: Color) -> Color
Converts the given color to an equivalent grayscale.
Sourcepub const fn color_from_u32(c: u32) -> Color
pub const fn color_from_u32(c: u32) -> Color
Color from u32
Sourcepub const fn color_to_u32(color: Color) -> u32
pub const fn color_to_u32(color: Color) -> u32
Color to u32
Sourcepub const fn interpolatec(c0: Color, c3: Color, dark_scale_to: u8) -> [Color; 8]
pub const fn interpolatec(c0: Color, c3: Color, dark_scale_to: u8) -> [Color; 8]
Calculates a linear interpolation for the two colors and fills the first 4 colors with it. The next 4 colors are scaled down versions using dark_scale_to.
Sourcepub const fn interpolate(c0: u32, c3: u32, dark_scale_to: u8) -> [Color; 8]
pub const fn interpolate(c0: u32, c3: u32, dark_scale_to: u8) -> [Color; 8]
Calculates a linear interpolation for the two colors and fills the first 4 colors with it. The next 4 colors are scaled down versions using dark_scale_to.
Sourcepub const fn interpolatec2(
c0: Color,
c3: Color,
c4: Color,
c7: Color,
) -> [Color; 8]
pub const fn interpolatec2( c0: Color, c3: Color, c4: Color, c7: Color, ) -> [Color; 8]
Calculates a linear interpolation for the two colors and fills the first 4 colors with it. The next 4 colors are scaled down versions using dark_scale_to.
Trait Implementations§
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