chore: remove image as a dependency

This commit is contained in:
2020-11-26 13:19:58 -06:00
parent de56024039
commit c96bf45bff
4 changed files with 4 additions and 74 deletions

View File

@@ -49,6 +49,9 @@ fn transform_mandelbrot_system(
if scale.zoom < 0.0 {
// We can't go below 0
scale.zoom -= scale.step * zoom as f64;
// slow down our step function
scale.step /= 10.0;
}
}

View File

@@ -1,8 +1,7 @@
use image::{ImageBuffer, Rgb, RgbImage};
use num_complex::Complex;
use rayon::prelude::*;
const MAX_ITERATIONS: u16 = 256;
const MAX_ITERATIONS: u16 = 1024;
#[derive(Debug, Clone)]
pub struct Mandelbrot {
@@ -126,36 +125,6 @@ impl Mandelbrot {
});
}
pub fn escape_time_image() {
let mut img: RgbImage = ImageBuffer::new(Self::IMG_WIDTH as u32, Self::IMG_HEIGHT as u32);
let mut mandelbrot: Vec<u16> = vec![0; Self::IMG_HEIGHT * Self::IMG_WIDTH];
mandelbrot
.par_iter_mut()
.enumerate()
.for_each(|(i, value)| {
let px = i % Self::IMG_WIDTH;
let py = i / Self::IMG_WIDTH;
let c = Self::coords_to_complex(px, py, (-2.5, 1.0), (-1.0, 1.0));
*value = Self::calc_num_iterations(c);
});
for (px, py, pixel) in img.enumerate_pixels_mut() {
let i = px as usize + Self::IMG_WIDTH * py as usize;
let num_iterations = mandelbrot[i];
match Self::find_colour(num_iterations) {
Colour::White => *pixel = Rgb([0x00, 0x00, 0x00]),
Colour::Black => *pixel = Rgb([0xFF, 0xFF, 0xFF]),
Colour::Gray => *pixel = Rgb([0xAA, 0xAA, 0xAA]),
}
}
img.save("assets/test.png").unwrap();
}
fn find_colour(iteration: u16) -> Colour {
match iteration {
MAX_ITERATIONS => Colour::Black,