[][src]Function termimage::ops::create_colourtable

pub fn create_colourtable<C: Index<usize, Output = u8>>(
    img: &DynamicImage,
    upper_colours: &[C],
    lower_colours: &[C]
) -> Vec<Vec<(usize, usize)>>

Create a line-major table of (upper, lower) colour approximation indices given the supported colours therefor.

Examples

Approximate img to ANSI and display it to stdout.

for line in create_colourtable(&img, &ANSI_COLOURS_WHITE_BG, &bg_colours_for(&ANSI_COLOURS_WHITE_BG)) {
    for (upper_clr, lower_clr) in line {
        print!("{}{}\u{2580}", // ▀
               ANSI_COLOUR_ESCAPES[upper_clr],
               ANSI_BG_COLOUR_ESCAPES[lower_clr]);
    }
    println!("{}{}", ANSI_COLOUR_ESCAPES[15], ANSI_BG_COLOUR_ESCAPES[0]);
}