pub fn rgb_from_ansi256(idx: u8) -> (u8, u8, u8)
Expand description

Returns sRGB colour corresponding to the index in the 256-colour ANSI palette.

The first 16 colours (so-called system colours) are not standardised and terminal emulators often allow them to be customised. Because of this, their value should not be relied upon. For system colours, this function returns default colours used by XTerm.

Remaining 240 colours consist of a 6×6×6 colour cube and a 24-step greyscale ramp. Those are standardised and thus should be the same on every terminal which supports 256-colour colour palette.

The palette can be viewed on helpful chart.

Examples

assert_eq!((  0,   0,   0), ansi_colours::rgb_from_ansi256( 16));
assert_eq!(( 95, 135, 175), ansi_colours::rgb_from_ansi256( 67));
assert_eq!((255, 255, 255), ansi_colours::rgb_from_ansi256(231));
assert_eq!((238, 238, 238), ansi_colours::rgb_from_ansi256(255));

let rgb = rgb::RGB8::from(ansi_colours::rgb_from_ansi256(128));
assert_eq!(rgb::RGB8 { r: 175, g: 0, b: 215 }, rgb);

let grey = rgb::alt::Gray::<u8>(128);
assert_eq!(244, ansi_colours::ansi256_from_rgb(grey));