rainbow_text/
rainbow_text.rs1use inksac::prelude::*;
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let text = "Rainbow Text Example";
7 let colors = [
8 (255, 0, 0), (255, 127, 0), (255, 255, 0), (0, 255, 0), (0, 0, 255), (75, 0, 130), (148, 0, 211), ];
16
17 for (i, c) in text.chars().enumerate() {
19 let color_idx = i % colors.len();
20 let (r, g, b) = colors[color_idx];
21
22 let style = Style::builder()
23 .foreground(Color::new_rgb(r, g, b)?)
24 .bold()
25 .build();
26
27 print!("{}", c.to_string().style(style));
28 }
29 println!();
30
31 Ok(())
32}