1use nu_ansi_term::{build_all_gradient_text, Color, Gradient, Rgb, TargetGround};
2
3fn main() {
4 let text = "lorem ipsum quia dolor sit amet, consectetur, adipisci velit";
5
6 // a gradient from hex colors
7 let start = Rgb::from_hex(0x40c9ff);
8 let end = Rgb::from_hex(0xe81cff);
9 let grad0 = Gradient::new(start, end);
10
11 // a gradient from color::rgb()
12 let start = Color::Rgb(64, 201, 255);
13 let end = Color::Rgb(232, 28, 255);
14 let gradient = Gradient::from_color_rgb(start, end);
15
16 // a slightly different gradient
17 let start2 = Color::Rgb(128, 64, 255);
18 let end2 = Color::Rgb(0, 28, 255);
19 let gradient2 = Gradient::from_color_rgb(start2, end2);
20
21 // reverse the gradient
22 let gradient3 = gradient.reverse();
23
24 let build_fg = gradient.build(text, TargetGround::Foreground);
25 println!("{}", build_fg);
26 let build_bg = gradient.build(text, TargetGround::Background);
27 println!("{}", build_bg);
28 let bgt = build_all_gradient_text(text, gradient, gradient2);
29 println!("{}", bgt);
30 let bgt2 = build_all_gradient_text(text, gradient, gradient3);
31 println!("{}", bgt2);
32
33 println!(
34 "{}",
35 grad0.build("nushell is awesome", TargetGround::Foreground)
36 );
37}
38