Struct Scheme

Source
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

Source

pub fn white(&self, n: usize) -> Style

Create a style from the given white shade. n is 0..=3

Source

pub fn black(&self, n: usize) -> Style

Create a style from the given black shade. n is 0..=3

Source

pub fn gray(&self, n: usize) -> Style

Create a style from the given gray shade. n is 0..=3

Source

pub fn red(&self, n: usize) -> Style

Create a style from the given red shade. n is 0..=3

Source

pub fn orange(&self, n: usize) -> Style

Create a style from the given orange shade. n is 0..=3

Source

pub fn yellow(&self, n: usize) -> Style

Create a style from the given yellow shade. n is 0..=3

Source

pub fn limegreen(&self, n: usize) -> Style

Create a style from the given limegreen shade. n is 0..=3

Source

pub fn green(&self, n: usize) -> Style

Create a style from the given green shade. n is 0..=3

Source

pub fn bluegreen(&self, n: usize) -> Style

Create a style from the given bluegreen shade. n is 0..=3

Source

pub fn cyan(&self, n: usize) -> Style

Create a style from the given cyan shade. n is 0..=3

Source

pub fn blue(&self, n: usize) -> Style

Create a style from the given blue shade. n is 0..=3

Source

pub fn deepblue(&self, n: usize) -> Style

Create a style from the given deepblue shade. n is 0..=3

Source

pub fn purple(&self, n: usize) -> Style

Create a style from the given purple shade. n is 0..=3

Source

pub fn magenta(&self, n: usize) -> Style

Create a style from the given magenta shade. n is 0..=3

Source

pub fn redpink(&self, n: usize) -> Style

Create a style from the given redpink shade. n is 0..=3

Source

pub fn primary(&self, n: usize) -> Style

Create a style from the given primary shade. n is 0..=3

Source

pub fn secondary(&self, n: usize) -> Style

Create a style from the given secondary shade. n is 0..=3

Source§

impl Scheme

Source

pub fn true_dark_white(&self, n: usize) -> Style

Create a style from the given white shade. n is 0..=3

Source

pub fn true_dark_black(&self, n: usize) -> Style

Create a style from the given black shade. n is 0..=3

Source

pub fn true_dark_gray(&self, n: usize) -> Style

Create a style from the given gray shade. n is 0..=3

Source

pub fn true_dark_red(&self, n: usize) -> Style

Create a style from the given red shade. n is 0..=3

Source

pub fn true_dark_orange(&self, n: usize) -> Style

Create a style from the given orange shade. n is 0..=3

Source

pub fn true_dark_yellow(&self, n: usize) -> Style

Create a style from the given yellow shade. n is 0..=3

Source

pub fn true_dark_limegreen(&self, n: usize) -> Style

Create a style from the given limegreen shade. n is 0..=3

Source

pub fn true_dark_green(&self, n: usize) -> Style

Create a style from the given green shade. n is 0..=3

Source

pub fn true_dark_bluegreen(&self, n: usize) -> Style

Create a style from the given bluegreen shade. n is 0..=3

Source

pub fn true_dark_cyan(&self, n: usize) -> Style

Create a style from the given cyan shade. n is 0..=3

Source

pub fn true_dark_blue(&self, n: usize) -> Style

Create a style from the given blue shade. n is 0..=3

Source

pub fn true_dark_deepblue(&self, n: usize) -> Style

Create a style from the given deepblue shade. n is 0..=3

Source

pub fn true_dark_purple(&self, n: usize) -> Style

Create a style from the given purple shade. n is 0..=3

Source

pub fn true_dark_magenta(&self, n: usize) -> Style

Create a style from the given magenta shade. n is 0..=3

Source

pub fn true_dark_redpink(&self, n: usize) -> Style

Create a style from the given redpink shade. n is 0..=3

Source

pub fn true_dark_primary(&self, n: usize) -> Style

Create a style from the given primary shade. n is 0..=3

Source

pub fn true_dark_secondary(&self, n: usize) -> Style

Create a style from the given secondary shade. n is 0..=3

Source§

impl Scheme

Source

pub fn reduced_white(&self, n: usize) -> Style

Create a style from the given white shade. n is 0..=3

Source

pub fn reduced_black(&self, n: usize) -> Style

Create a style from the given black shade. n is 0..=3

Source

pub fn reduced_gray(&self, n: usize) -> Style

Create a style from the given gray shade. n is 0..=3

Source

pub fn reduced_red(&self, n: usize) -> Style

Create a style from the given red shade. n is 0..=3

Source

pub fn reduced_orange(&self, n: usize) -> Style

Create a style from the given orange shade. n is 0..=3

Source

pub fn reduced_yellow(&self, n: usize) -> Style

Create a style from the given yellow shade. n is 0..=3

Source

pub fn reduced_limegreen(&self, n: usize) -> Style

Create a style from the given limegreen shade. n is 0..=3

Source

pub fn reduced_green(&self, n: usize) -> Style

Create a style from the given green shade. n is 0..=3

Source

pub fn reduced_bluegreen(&self, n: usize) -> Style

Create a style from the given bluegreen shade. n is 0..=3

Source

pub fn reduced_cyan(&self, n: usize) -> Style

Create a style from the given cyan shade. n is 0..=3

Source

pub fn reduced_blue(&self, n: usize) -> Style

Create a style from the given blue shade. n is 0..=3

Source

pub fn reduced_deepblue(&self, n: usize) -> Style

Create a style from the given deepblue shade. n is 0..=3

Source

pub fn reduced_purple(&self, n: usize) -> Style

Create a style from the given purple shade. n is 0..=3

Source

pub fn reduced_magenta(&self, n: usize) -> Style

Create a style from the given magenta shade. n is 0..=3

Source

pub fn reduced_redpink(&self, n: usize) -> Style

Create a style from the given redpink shade. n is 0..=3

Source

pub fn reduced_primary(&self, n: usize) -> Style

Create a style from the given primary shade. n is 0..=3

Source

pub fn reduced_secondary(&self, n: usize) -> Style

Create a style from the given secondary shade. n is 0..=3

Source§

impl Scheme

Source

pub fn style(&self, color: Color) -> Style

Create a style with the given background color. Foreground is calculated with text_color.

Source

pub fn reduced_style(&self, color: Color) -> Style

Create a style with the given background color. Foreground is calculated with reduced_text_color.

Source

pub fn true_dark_style(&self, color: Color) -> Style

Create a style with the given background color converted with true_dark_color(). Foreground is calculated with text_color.

Source

pub fn reduced_dark_style(&self, color: Color) -> Style

Create a style with the given background color. converted with true_dark_color(). Foreground is calculated with reduced_text_color.

Source

pub const fn linear4(c0: u32, c1: u32) -> [Color; 4]

Linear interpolation between the two colors.

Source

pub fn true_dark_color(&self, color: Color) -> Color

Reduces the range of the given color from 0..255 to 0..63.

This gives a true dark equivalent which can be used as a background for a dark theme.

Source

pub fn grey_color(&self, color: Color) -> Color

Converts the given color to an equivalent grayscale.

Source

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.

Source

pub fn reduced_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.

Source

pub fn rate_text_color(&self, color: Color) -> Option<bool>

This gives back true or false for text foreground where true means light and false means a dark text-color 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§

Source§

impl Clone for Scheme

Source§

fn clone(&self) -> Scheme

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scheme

Source§

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

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

impl Default for Scheme

Source§

fn default() -> Scheme

Returns the “default value” for a type. Read more

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> 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.