diff --git a/src/main.rs b/src/main.rs index be66d9a..9221c07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use std::{ }; use bracket_color::prelude::{HSV, RGB}; -use clap::{Parser, Subcommand}; +use clap::{Parser, Subcommand, ValueEnum}; use image::{imageops::FilterType, io::Reader as ImageReader, Pixel, Rgb, RgbImage}; use rand::Rng; @@ -80,12 +80,25 @@ impl From for Rgb { #[derive(Clone, Debug, PartialEq, Eq, Subcommand)] enum Action { - Rainbow, - Solid { color: Color }, - Image { path: PathBuf }, + Animation { + #[clap(value_enum)] + animation: Animation, + }, + Solid { + color: Color, + }, + Image { + path: PathBuf, + }, Clear, } +#[derive(Clone, Debug, PartialEq, Eq, ValueEnum)] +enum Animation { + Rainbow, + Bling, +} + fn bling(layout: Layout, frame: u32) -> RgbImage { #![allow( clippy::cast_precision_loss, @@ -190,13 +203,18 @@ fn main() -> anyhow::Result<()> { .decode()? .resize_to_fill(layout.width_px(), layout.height_px(), FilterType::Gaussian) .into_rgb8(), - Action::Rainbow => { + Action::Animation { animation } => { + let f = match animation { + Animation::Rainbow => rainbow, + Animation::Bling => bling, + }; + print!("{}", termion::clear::All); let mut frame = 0; loop { let start = Instant::now(); - let image = rainbow(layout, frame); + let image = f(layout, frame); print_image(&image);