34 lines
567 B
Rust
34 lines
567 B
Rust
|
use std::{fs::File, path::PathBuf};
|
||
|
|
||
|
use anyhow::Result;
|
||
|
use clap::Parser;
|
||
|
|
||
|
use crate::value_noise::generate_noise;
|
||
|
|
||
|
mod ppm;
|
||
|
mod value_noise;
|
||
|
mod vec2;
|
||
|
|
||
|
#[derive(Parser)]
|
||
|
struct Opt {
|
||
|
#[clap(short = 'o', long = "out", default_value = "out.ppm")]
|
||
|
output_path: PathBuf,
|
||
|
}
|
||
|
|
||
|
fn main() -> Result<()> {
|
||
|
let opt = Opt::parse();
|
||
|
|
||
|
let rng = rand::thread_rng();
|
||
|
|
||
|
let width = 256;
|
||
|
let height = 256;
|
||
|
let ppm = generate_noise(width, height, rng);
|
||
|
|
||
|
{
|
||
|
let file = File::create(opt.output_path)?;
|
||
|
ppm.write(file)?;
|
||
|
}
|
||
|
|
||
|
Ok(())
|
||
|
}
|