pub struct Rgb {
pub r: u8,
pub g: u8,
pub b: u8,
}Expand description
RGB color, with u8 components
Fields§
§r: u8red
g: u8green
b: u8blue
Implementations§
source§impl Rgb
impl Rgb
pub const fn is_grey(self) -> bool
sourcepub fn to_ansi_slow(self) -> AnsiColor
pub fn to_ansi_slow(self) -> AnsiColor
Return the nearest ANSI color
This is a slow function as it literally tries all ANSI colors and picks the nearest one.
sourcepub fn to_ansi(self) -> AnsiColor
pub fn to_ansi(self) -> AnsiColor
Return the nearest ANSI color
This uses the excellent ansi_colours crate, as it’s very fast and gives rather good conversions
pub fn mix(c1: Self, w1: f32, c2: Self, w2: f32) -> Self
pub fn to_hsl(self) -> Hsl
pub fn parts(self) -> (f32, f32, f32)
sourcepub fn luma(self) -> f32
pub fn luma(self) -> f32
Compute the Luma value characterizing the “light” of the color, going from 0 (black) to 1 (white).
Reference: https://en.wikipedia.org/wiki/Luma_(video)
sourcepub fn distance_to<O: Into<Rgb>>(self, other: O) -> f32
pub fn distance_to<O: Into<Rgb>>(self, other: O) -> f32
tentatively perceptual distance between two RGB colors (adapted from the ansi_colours crate, by mina86, who adapted a formula found at https://www.compuphase.com/cmetric.htm)
Trait Implementations§
impl Copy for Rgb
impl Eq for Rgb
impl StructuralEq for Rgb
impl StructuralPartialEq for Rgb
Auto Trait Implementations§
impl RefUnwindSafe for Rgb
impl Send for Rgb
impl Sync for Rgb
impl Unpin for Rgb
impl UnwindSafe for Rgb
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