RGBColor

Struct RGBColor 

Source
pub struct RGBColor {
    pub r: u8,
    pub g: u8,
    pub b: u8,
}
Expand description

Defines an RGB color used for foreground and background coloring of text. r, g, b are the red, green and blue components of the color respectively.

Fields§

§r: u8§g: u8§b: u8

Implementations§

Source§

impl RGBColor

Source

pub const BLACK: Self

Source

pub const DARK_GRAY: Self

Source

pub const GRAY: Self

Source

pub const LIGHT_GRAY: Self

Source

pub const WHITE: Self

Source

pub const RED: Self

Source

pub const GREEN: Self

Source

pub const BLUE: Self

Source

pub const YELLOW: Self

Source

pub const CYAN: Self

Source

pub const MAGENTA: Self

Trait Implementations§

Source§

impl Clone for RGBColor

Source§

fn clone(&self) -> RGBColor

Returns a duplicate 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 Color for RGBColor

Source§

fn blend(color_top: &Self, _color_bottom: &Self) -> Self

Blends the top with the bottom color. In the case of opaque colors this simply returns the top color. If the top color is completely transparent it returns the bottom color. For a translucent top color this returns a mix of both colors weighted by their opacity. Read more
Source§

fn color(text: &str, foreground_color: &Self, background_color: &Self) -> String

Colors a text with a foreground and background color. Read more
Source§

fn distance(color1: &Self, color2: &Self) -> f32

Calculates the relative distance between two colors. For smaller distances the returned value is smaller. There are no guarantees for the exact return value, so this has only meaning in comparisons. Read more
Source§

fn mix(colors: &[Self]) -> Self

Mixes a list of colors into one. Read more
Source§

fn group<const N: usize>(colors: &[Self; N]) -> [bool; N]

Groups a list of colors into two groups. The groups are formed by finding the most distant colors. All other colors are then put into a group with one of them depending on which distance is smaller. Returns an array of the size of the input. True and false are used to map each color into one of two groups. Read more
Source§

impl Debug for RGBColor

Source§

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

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

impl From<RGBColor> for ARGBColor

Source§

fn from(value: RGBColor) -> Self

Converts to this type from the input type.
Source§

impl From<RGBColor> for TerminalColor

Source§

fn from(value: RGBColor) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RGBColor

Source§

fn eq(&self, other: &RGBColor) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RGBColor

Source§

impl Eq for RGBColor

Source§

impl StructuralPartialEq for RGBColor

Auto Trait Implementations§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> 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.