mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-12-23 06:36:42 +00:00
Add fill modes
This commit is contained in:
parent
57bbb6e9a7
commit
1bc267461a
16
src/fill/level.rs
Normal file
16
src/fill/level.rs
Normal file
@ -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
|
||||
}
|
||||
}
|
35
src/fill/mod.rs
Normal file
35
src/fill/mod.rs
Normal file
@ -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<FillModeEnum>, 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<dyn FillMode> {
|
||||
match mode {
|
||||
FillModeEnum::Circle => todo!(),
|
||||
FillModeEnum::Level => Box::new(LevelFillMode::new()),
|
||||
FillModeEnum::Stripe => todo!()
|
||||
}
|
||||
}
|
@ -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<FillModeEnum>,
|
||||
#[clap(short, long, help = "Add color pallet", arg_enum)]
|
||||
pallet: Vec<PalletEnum>,
|
||||
#[clap(long, default_value = ".-+%#", help = "Set chars")]
|
||||
|
Loading…
Reference in New Issue
Block a user