pub struct Rgb {
pub r: u8,
pub g: u8,
pub b: u8,
}
Expand description
RGB color, with u8 components
Fields§
§r: u8
red
g: u8
green
b: u8
blue
Implementations§
Source§impl Rgb
impl Rgb
pub const fn is_grey(self) -> bool
pub fn nearest_ansi_in_range(self, min: u8, max: u8) -> AnsiColor
Sourcepub fn to_ansi(self) -> AnsiColor
pub fn to_ansi(self) -> AnsiColor
Return the nearest ANSI color
The ansi->rgb->ansi round trip is guaranteed to always fall on the first color.
pub fn mix(c1: Rgb, w1: f32, c2: Rgb, w2: f32) -> Rgb
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>(self, other: O) -> f32
pub fn distance_to<O>(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 StructuralPartialEq for Rgb
Auto Trait Implementations§
impl Freeze for Rgb
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