mandelbruhst-cli 0.1.0

a command-line tool for plotting images of the mandelbrot set
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use anyhow::{Context, Result};
use clap::Parser;
use image::ImageBuffer;
use mandelbruhst_cli::opts::Cli;

fn main() -> Result<()> {
    let args = Cli::parse();
    let hue_array = args.get_hue_array()?;
    let (width, height) = args.resolution.to_dimensions();
    let palette = args.get_palette()?;
    let img = ImageBuffer::from_fn(width as u32, height as u32, |x, y| {
        let frac = hue_array[x as usize][y as usize];
        palette.value(frac)
    });
    img.save(&args.out_file).context("problem saving image")?;
    Ok(())
}