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: u8Implementations§
Source§impl RGBColor
impl RGBColor
pub const BLACK: Self
pub const DARK_GRAY: Self
pub const GRAY: Self
pub const LIGHT_GRAY: Self
pub const WHITE: Self
pub const RED: Self
pub const GREEN: Self
pub const BLUE: Self
pub const YELLOW: Self
pub const CYAN: Self
pub const MAGENTA: Self
Trait Implementations§
Source§impl Color for RGBColor
impl Color for RGBColor
Source§fn blend(color_top: &Self, _color_bottom: &Self) -> Self
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
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
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 group<const N: usize>(colors: &[Self; N]) -> [bool; N]
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 From<RGBColor> for TerminalColor
impl From<RGBColor> for TerminalColor
impl Copy for RGBColor
impl Eq for RGBColor
impl StructuralPartialEq for RGBColor
Auto Trait Implementations§
impl Freeze for RGBColor
impl RefUnwindSafe for RGBColor
impl Send for RGBColor
impl Sync for RGBColor
impl Unpin for RGBColor
impl UnwindSafe for RGBColor
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
Mutably borrows from an owned value. Read more