1extern crate nu_ansi_term;
2use nu_ansi_term::{Color, Style};
3
4// This example prints out a color gradient in a grid by calculating each
5// character’s red, green, and blue components, and using 24-bit color codes
6// to display them.
7
8const WIDTH: i32 = 80;
9const HEIGHT: i32 = 24;
10
11fn main() {
12 for row in 0..HEIGHT {
13 for col in 0..WIDTH {
14 let r = (row * 255 / HEIGHT) as u8;
15 let g = (col * 255 / WIDTH) as u8;
16 let b = 128;
17
18 print!("{}", Style::default().on(Color::Rgb(r, g, b)).paint(" "));
19 }
20
21 println!();
22 }
23}
24