use owo_colors::OwoColorize;
use prismatica::matplotlib::VIRIDIS;
fn main() {
println!(
"Colormap: {} ({})\n",
VIRIDIS.meta.name, VIRIDIS.meta.collection
);
println!("Per-character gradient:");
let text = "Perceptually uniform colormaps for scientific visualization";
print!(" ");
for (i, ch) in text.chars().enumerate() {
let t = i as f32 / (text.len() - 1) as f32;
let rgb: owo_colors::Rgb = VIRIDIS.eval(t).into();
print!("{}", ch.color(rgb));
}
println!();
println!("\nBackground gradient (32 steps):");
print!(" ");
for i in 0..32 {
let t = i as f32 / 31.0;
let rgb: owo_colors::Rgb = VIRIDIS.eval(t).into();
print!("{}", " ".on_color(rgb));
}
println!();
println!("\nLabeled swatches:");
for i in 0..8 {
let t = i as f32 / 7.0;
let pc = VIRIDIS.eval(t);
let rgb: owo_colors::Rgb = pc.into();
let label = format!(" t={t:.2} ({:>3},{:>3},{:>3}) ", pc.r, pc.g, pc.b);
println!(" {}", label.on_color(rgb).bold());
}
println!("\nForeground vs background:");
for i in 0..6 {
let t = i as f32 / 5.0;
let rgb: owo_colors::Rgb = VIRIDIS.eval(t).into();
let fg_text = format!(" Foreground at t={t:.2} ");
let bg_text = format!(" Background at t={t:.2} ");
println!(" {} {}", fg_text.color(rgb).bold(), bg_text.on_color(rgb),);
}
}