Depth binds & rust things

master
E. Almqvist 3 years ago
parent 396862ded5
commit 9105c2adcf
  1. 22
      mas/fractals/mandel/src/main.rs
  2. 6
      mas/fractals/mandel/src/render.rs

@ -77,18 +77,28 @@ fn main() {
zy *= zoom_out; zy *= zoom_out;
zx *= zoom_out; zx *= zoom_out;
}, },
Event::KeyDown { keycode: Some(Keycode::W), .. } => {
println!("(+) DEPTH= {depth}");
render_new = true;
depth *= 2;
},
Event::KeyDown { keycode: Some(Keycode::S), .. } => {
println!("(-) DEPTH= {depth}");
render_new = true;
depth /= 2;
},
_ => {} _ => {}
} }
} }
if render_new { if render_new {
let mut maps = &mut Vec::new(); let maps = &mut Vec::new();
for thread_id in 0..threads { for thread_id in 0..threads {
thread::spawn(|| { // do cool threads for performance thread::spawn(|| {
let mut pixmap = render::prerender_mandelbrot( let pixmap = render::prerender_mandelbrot(
width, height, depth, &width, &height, &depth,
zx, zy, dx, dy, &zx, &zy, &dx, &dy,
thread_id, threads, w_sector_size, h_sector_size); &thread_id, &threads, &w_sector_size, &h_sector_size);
maps.push(pixmap); maps.push(pixmap);
}); });
} }

@ -66,10 +66,10 @@ pub fn set_pixel(canvas: &mut Canvas<sdl2::video::Window>, x: i32, y: i32, color
canvas.fill_rect(Rect::new(x, y, 1, 1)); canvas.fill_rect(Rect::new(x, y, 1, 1));
} }
pub fn prerender_mandelbrot(w: u32, h: u32, depth: u32, xzoom: f32, yzoom: f32, xoffset: f32, yoffset: f32, thread_id: u32, threads: u32, w_sector_size: u32, h_sector_size: u32) -> PixelMap { pub fn prerender_mandelbrot(w: &u32, h: &u32, depth: &u32, xzoom: &f32, yzoom: &f32, xoffset: &f32, yoffset: &f32, thread_id: &u32, threads: &u32, w_sector_size: &u32, h_sector_size: &u32) -> PixelMap {
println!("Rendering..."); println!("Rendering...");
let mut pixmap = PixelMap::new(w, h, thread_id * w_sector_size, thread_id * h_sector_size); let mut pixmap = PixelMap::new(*w, *h, thread_id * w_sector_size, thread_id * h_sector_size);
mandelbrot(&mut pixmap, w, h, depth, xzoom, yzoom, xoffset, yoffset); mandelbrot(&mut pixmap, *w, *h, *depth, *xzoom, *yzoom, *xoffset, *yoffset);
println!("Post mandel render"); println!("Post mandel render");
return pixmap; return pixmap;

Loading…
Cancel
Save