pub struct Palette {Show 17 fields
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§
§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 BRIGHT_0: usize = 0usize
pub const BRIGHT_0: usize = 0usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const BRIGHT_1: usize = 1usize
pub const BRIGHT_1: usize = 1usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const BRIGHT_2: usize = 2usize
pub const BRIGHT_2: usize = 2usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const BRIGHT_3: usize = 3usize
pub const BRIGHT_3: usize = 3usize
Color index for a bright variant of the base color. Brightness increases with the number.
Sourcepub const DARK_0: usize = 4usize
pub const DARK_0: usize = 4usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub const DARK_1: usize = 5usize
pub const DARK_1: usize = 5usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub const DARK_2: usize = 6usize
pub const DARK_2: usize = 6usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub const DARK_3: usize = 7usize
pub const DARK_3: usize = 7usize
Color index for a dark variant of the base color. Brightness increases with the number.
Sourcepub fn white(&self, n: usize, contrast: Contrast) -> Style
pub fn white(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given white shade.
n is 0..=3
Sourcepub fn black(&self, n: usize, contrast: Contrast) -> Style
pub fn black(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given black shade.
n is 0..=3
Sourcepub fn gray(&self, n: usize, contrast: Contrast) -> Style
pub fn gray(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given gray shade.
n is 0..=3
Sourcepub fn red(&self, n: usize, contrast: Contrast) -> Style
pub fn red(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given red shade.
n is 0..=3
Sourcepub fn orange(&self, n: usize, contrast: Contrast) -> Style
pub fn orange(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given orange shade.
n is 0..=3
Sourcepub fn yellow(&self, n: usize, contrast: Contrast) -> Style
pub fn yellow(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given yellow shade.
n is 0..=3
Sourcepub fn limegreen(&self, n: usize, contrast: Contrast) -> Style
pub fn limegreen(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given limegreen shade.
n is 0..=3
Sourcepub fn green(&self, n: usize, contrast: Contrast) -> Style
pub fn green(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given green shade.
n is 0..=3
Sourcepub fn bluegreen(&self, n: usize, contrast: Contrast) -> Style
pub fn bluegreen(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given bluegreen shade.
n is 0..=3
Sourcepub fn cyan(&self, n: usize, contrast: Contrast) -> Style
pub fn cyan(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given cyan shade.
n is 0..=3
Sourcepub fn blue(&self, n: usize, contrast: Contrast) -> Style
pub fn blue(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given blue shade.
n is 0..=3
Sourcepub fn deepblue(&self, n: usize, contrast: Contrast) -> Style
pub fn deepblue(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given deepblue shade.
n is 0..=3
Sourcepub fn purple(&self, n: usize, contrast: Contrast) -> Style
pub fn purple(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given purple shade.
n is 0..=3
Sourcepub fn magenta(&self, n: usize, contrast: Contrast) -> Style
pub fn magenta(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given magenta shade.
n is 0..=3
Sourcepub fn redpink(&self, n: usize, contrast: Contrast) -> Style
pub fn redpink(&self, n: usize, contrast: Contrast) -> Style
Create a style from the given redpink shade.
n is 0..=3
Source§impl Palette
impl Palette
Sourcepub fn style(&self, color: Color, contrast: Contrast) -> Style
pub fn style(&self, color: Color, contrast: Contrast) -> Style
Create a style with the given background color and contrast.
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 white[0] or black[3] for the foreground,
based on rate_text_color.
Sourcepub const fn rate_text_color(color: Color) -> Option<TextColorRating>
pub const fn rate_text_color(color: Color) -> Option<TextColorRating>
This gives back a TextColorRating for the given background.
This converts RGB to grayscale and takes the grayscale value of VGA cyan as threshold, which is about 105 out of 255. This point is a bit arbitrary, just based on what I perceive as acceptable. But it produces a good reading contrast in my experience.
For the named colors it takes the VGA equivalent as a base. For indexed colors it splits the range in half as an estimate.
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§
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<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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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