use std::{fs::File, path::PathBuf}; use anyhow::Result; use clap::{Parser, ValueEnum}; use turbulence::generate_turbulence; use crate::value_noise::generate_noise; mod ppm; mod turbulence; mod value_noise; mod vec2; #[derive(Parser)] struct Opt { #[clap(long = "algorithm", default_value = "turbulence")] algorithm: Algorithm, #[clap(long = "size", default_value = "1024")] size: usize, #[clap(short = 'o', long = "out", default_value = "out.ppm")] output_path: PathBuf, } #[derive(ValueEnum, Clone)] enum Algorithm { Noise, Turbulence, } fn main() -> Result<()> { let opt = Opt::parse(); let rng = rand::thread_rng(); let ppm = match opt.algorithm { Algorithm::Noise => generate_noise(opt.size, opt.size, rng), Algorithm::Turbulence => generate_turbulence(opt.size, opt.size, rng), }; { let file = File::create(opt.output_path)?; ppm.write(file)?; } Ok(()) }