Function ansi_colours::rgb_from_ansi256[][src]

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

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.

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));