pub fn ansi256_from_grey(component: u8) -> u8
Expand description

Returns index of a colour in 256-colour ANSI palette approximating given shade of grey.

This gives the same results as ansi256_from_rgb((component, component, component)) but is faster. Provided that the rgb crate feature is enabled, it is equivalent (in behaviour and performance) to ansi256_from_rgb(rgb::alt::Grey(component)).

Examples

assert_eq!( 16, ansi_colours::ansi256_from_grey(0));
assert_eq!( 16, ansi_colours::ansi256_from_grey(1));
assert_eq!(231, ansi_colours::ansi256_from_grey(255));

let grey = rgb::alt::Gray::<u8>(128);
assert_eq!(244, ansi_colours::ansi256_from_grey(*grey));
assert_eq!(244, ansi_colours::ansi256_from_rgb(grey));
Examples found in repository?
src/impls.rs (line 95)
95
    fn to_ansi256(&self) -> u8 { crate::ansi256_from_grey(self.into_u8()) }