rainbow_text/
rainbow_text.rs

1//! Example demonstrating text with gradient colors
2
3use inksac::prelude::*;
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let text = "Rainbow Text Example";
7    let colors = [
8        (255, 0, 0),   // Red
9        (255, 127, 0), // Orange
10        (255, 255, 0), // Yellow
11        (0, 255, 0),   // Green
12        (0, 0, 255),   // Blue
13        (75, 0, 130),  // Indigo
14        (148, 0, 211), // Violet
15    ];
16
17    // Print each character with a different color
18    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}