1 extern crate ansi_term; 2 use ansi_term::{Style, Colour}; 3 4 // This example prints out a colour gradient in a grid by calculating each 5 // character’s red, green, and blue components, and using 24-bit colour codes 6 // to display them. 7 8 const WIDTH: i32 = 80; 9 const HEIGHT: i32 = 24; 10 11 fn 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(Colour::RGB(r, g, b)).paint(" ")); 19 } 20 TEST(Numeric,Aint)21 print!("\n"); 22 } 23 } 24