Tunal/crates/tunal-theme/examples/dump.rs
astar76 7f94978bfb S002: portal appearance reader, watcher and Material palettes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 09:33:29 -06:00

41 lines
1.4 KiB
Rust

//! Prints the portal appearance and a few palette roles.
//! With `--watch`, keeps running and prints each appearance change.
fn main() {
let appearance = tunal_theme::read();
match appearance.accent {
Some(a) => println!(
"accent: ({:.6}, {:.6}, {:.6}) = #{:06X}",
a.red,
a.green,
a.blue,
a.rgb()
),
None => println!(
"accent: none (fallback seed #{:06X})",
tunal_theme::FALLBACK_SEED
),
}
println!("scheme: {:?}", appearance.scheme);
println!("animations: {:?}", appearance.animations);
println!("seed: #{:06X}", appearance.seed());
let palette = appearance.palette();
for (role, argb) in [
("primary", palette.primary),
("on_primary", palette.on_primary),
("primary_container", palette.primary_container),
("secondary_container", palette.secondary_container),
("surface", palette.surface),
("surface_container", palette.surface_container),
("on_surface", palette.on_surface),
("outline", palette.outline),
] {
println!("{role:<20} #{argb:08X}");
}
if std::env::args().any(|arg| arg == "--watch") {
let watcher = tunal_theme::watch(|appearance| println!("changed: {appearance:?}"));
let _ = watcher.join();
}
}