use cursive_core::theme::Color as CursiveColor;
use prismatica::Color;
use prismatica::matplotlib::VIRIDIS;
fn main() {
let cm = &VIRIDIS;
let n = 8;
println!("Colormap: {} ({})\n", cm.meta.name, cm.meta.collection);
println!(
" {:<4} {:>3} {:>3} {:>3} cursive variant",
"i", "R", "G", "B"
);
println!(" {}", "-".repeat(44));
for i in 0..n {
let color = cm.eval_rational(i, n);
let cursive: CursiveColor = color.into();
let back: Color = cursive.try_into().expect("Rgb variant always succeeds");
let swatch = format!("\x1b[48;2;{};{};{}m \x1b[0m", back.r, back.g, back.b);
println!(
" {:<4} {:>3} {:>3} {:>3} {:?} {}",
i, color.r, color.g, color.b, cursive, swatch
);
assert_eq!(color, back, "round-trip failed at index {i}");
}
println!("\nAll {n} samples round-tripped through cursive_core::theme::Color::Rgb.");
}