diff --git a/src/fill/level.rs b/src/fill/level.rs new file mode 100644 index 0000000..04da362 --- /dev/null +++ b/src/fill/level.rs @@ -0,0 +1,16 @@ +use crate::fill::FillMode; +use crate::vec::Vector; + +pub struct LevelFillMode; + +impl LevelFillMode { + pub fn new() -> Self { + Self { } + } +} + +impl FillMode for LevelFillMode { + fn sample(&self, level: f32, _: Vector) -> f32 { + level + } +} \ No newline at end of file diff --git a/src/fill/mod.rs b/src/fill/mod.rs new file mode 100644 index 0000000..2a6ecf9 --- /dev/null +++ b/src/fill/mod.rs @@ -0,0 +1,35 @@ +mod level; + +use clap::ArgEnum; +use rand::prelude::IteratorRandom; +use rand::Rng; +use crate::fill::level::LevelFillMode; +use crate::vec::Vector; + +pub trait FillMode { + fn sample(&self, level: f32, pos: Vector) -> f32; +} + +#[derive(Copy, Clone, ArgEnum)] +pub enum FillModeEnum { + Circle, + Level, + Stripe +} + +pub fn choose_fill_mode(mut options: Vec, rng: &mut impl Rng) -> FillModeEnum { + if options.is_empty() { + options.push(FillModeEnum::Circle); + options.push(FillModeEnum::Level); + options.push(FillModeEnum::Stripe); + } + options.into_iter().choose(rng).unwrap() +} + +pub fn create_fill_mode(mode: FillModeEnum, _: Vector) -> Box { + match mode { + FillModeEnum::Circle => todo!(), + FillModeEnum::Level => Box::new(LevelFillMode::new()), + FillModeEnum::Stripe => todo!() + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 2004c2c..455264d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,19 @@ use clap::Parser; use rand::rngs::OsRng; use crate::char::CharSampler; +use crate::fill::FillModeEnum; use crate::pallet::{choose_pallet, create_pallet, PalletEnum}; mod pallet; mod char; +mod fill; +mod vec; #[derive(Parser)] #[clap(author = "Rico Riedel", version = "0.1.0", about = "Wipe your terminal with a random animation.")] struct Args { + #[clap(short, long, help = "Add fill mode", arg_enum)] + fill: Vec, #[clap(short, long, help = "Add color pallet", arg_enum)] pallet: Vec, #[clap(long, default_value = ".-+%#", help = "Set chars")]