pub struct Scheme {Show 17 fields
pub white: [Color; 4],
pub black: [Color; 4],
pub gray: [Color; 4],
pub red: [Color; 4],
pub orange: [Color; 4],
pub yellow: [Color; 4],
pub limegreen: [Color; 4],
pub green: [Color; 4],
pub bluegreen: [Color; 4],
pub cyan: [Color; 4],
pub blue: [Color; 4],
pub deepblue: [Color; 4],
pub purple: [Color; 4],
pub magenta: [Color; 4],
pub redpink: [Color; 4],
pub primary: [Color; 4],
pub secondary: [Color; 4],
}Expand description
Color scheme.
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.
Fields§
§white: [Color; 4]§black: [Color; 4]§gray: [Color; 4]§red: [Color; 4]§orange: [Color; 4]§yellow: [Color; 4]§limegreen: [Color; 4]§green: [Color; 4]§bluegreen: [Color; 4]§cyan: [Color; 4]§blue: [Color; 4]§deepblue: [Color; 4]§purple: [Color; 4]§magenta: [Color; 4]§redpink: [Color; 4]§primary: [Color; 4]§secondary: [Color; 4]Implementations§
Source§impl Scheme
impl Scheme
Sourcepub fn style(&self, color: Color) -> Style
pub fn style(&self, color: Color) -> Style
Create a style with the given background color.
Foreground is calculated with text_color.
Sourcepub const fn linear4(c0: u32, c1: u32) -> [Color; 4]
pub const fn linear4(c0: u32, c1: u32) -> [Color; 4]
Linear interpolation between the two colors.
Sourcepub fn true_dark_color(&self, color: Color) -> Color
pub fn true_dark_color(&self, color: Color) -> Color
Reduces the range of the given color from 0..255 to 0..85.
This gives a true dark equivalent which can be used as a background for a dark theme.
Sourcepub fn grey_color(&self, color: Color) -> Color
pub fn grey_color(&self, color: Color) -> Color
Converts the given color to an equivalent grayscale.
Sourcepub fn text_color(&self, color: Color) -> Color
pub fn text_color(&self, color: Color) -> Color
This gives back white[3] or black[0] for text foreground
providing good contrast to 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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scheme
impl RefUnwindSafe for Scheme
impl Send for Scheme
impl Sync for Scheme
impl Unpin for Scheme
impl UnwindSafe for Scheme
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