chore: remove image as a dependency
This commit is contained in:
parent
de56024039
commit
c96bf45bff
|
@ -1751,16 +1751,6 @@ dependencies = [
|
||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gif"
|
|
||||||
version = "0.11.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "02efba560f227847cb41463a7395c514d127d4f74fff12ef0137fff1b84b96c4"
|
|
||||||
dependencies = [
|
|
||||||
"color_quant",
|
|
||||||
"weezl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gilrs"
|
name = "gilrs"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -1922,14 +1912,11 @@ dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"color_quant",
|
"color_quant",
|
||||||
"gif",
|
|
||||||
"jpeg-decoder",
|
|
||||||
"num-iter",
|
"num-iter",
|
||||||
"num-rational",
|
"num-rational",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"png",
|
"png",
|
||||||
"scoped_threadpool",
|
"scoped_threadpool",
|
||||||
"tiff",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2044,16 +2031,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "jpeg-decoder"
|
|
||||||
version = "0.1.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cc797adac5f083b8ff0ca6f6294a999393d76e197c36488e2ef732c4715f6fa3"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
"rayon",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.45"
|
version = "0.3.45"
|
||||||
|
@ -2192,7 +2169,6 @@ name = "mandelbrot"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"image",
|
|
||||||
"num-complex",
|
"num-complex",
|
||||||
"rayon",
|
"rayon",
|
||||||
]
|
]
|
||||||
|
@ -3293,17 +3269,6 @@ version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7572415bd688d401c52f6e36f4c8e805b9ae1622619303b9fa835d531db0acae"
|
checksum = "7572415bd688d401c52f6e36f4c8e805b9ae1622619303b9fa835d531db0acae"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tiff"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "abeb4e3f32a8973722c0254189e6890358e72b1bf11becb287ee0b23c595a41d"
|
|
||||||
dependencies = [
|
|
||||||
"jpeg-decoder",
|
|
||||||
"miniz_oxide 0.4.3",
|
|
||||||
"weezl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.44"
|
version = "0.1.44"
|
||||||
|
@ -3608,12 +3573,6 @@ dependencies = [
|
||||||
"webpki",
|
"webpki",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "weezl"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3e2bb9fc8309084dd7cd651336673844c1d47f8ef6d2091ec160b27f5c4aa277"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu"
|
name = "wgpu"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
|
|
@ -8,6 +8,5 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.3"
|
bevy = "0.3"
|
||||||
image = "0.23"
|
|
||||||
num-complex = "0.3"
|
num-complex = "0.3"
|
||||||
rayon = "1.5"
|
rayon = "1.5"
|
||||||
|
|
|
@ -49,6 +49,9 @@ fn transform_mandelbrot_system(
|
||||||
if scale.zoom < 0.0 {
|
if scale.zoom < 0.0 {
|
||||||
// We can't go below 0
|
// We can't go below 0
|
||||||
scale.zoom -= scale.step * zoom as f64;
|
scale.zoom -= scale.step * zoom as f64;
|
||||||
|
|
||||||
|
// slow down our step function
|
||||||
|
scale.step /= 10.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use image::{ImageBuffer, Rgb, RgbImage};
|
|
||||||
use num_complex::Complex;
|
use num_complex::Complex;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
const MAX_ITERATIONS: u16 = 256;
|
const MAX_ITERATIONS: u16 = 1024;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Mandelbrot {
|
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 {
|
fn find_colour(iteration: u16) -> Colour {
|
||||||
match iteration {
|
match iteration {
|
||||||
MAX_ITERATIONS => Colour::Black,
|
MAX_ITERATIONS => Colour::Black,
|
||||||
|
|
Loading…
Reference in New Issue