diff --git a/src/main.rs b/src/main.rs index 08dabaa..abdcdc4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,7 +109,7 @@ fn startup( mut materials: ResMut>, ) { let img_size = Vec2::new(Mandelbrot::width() as f32, Mandelbrot::height() as f32); - let img_buf = Mandelbrot::new().generate_image(); + let img_buf = Mandelbrot::new().generate_image().to_vec(); let texture_handle = textures.add(Texture::new( img_size, diff --git a/src/mandelbrot.rs b/src/mandelbrot.rs index 654c876..0dfe95f 100644 --- a/src/mandelbrot.rs +++ b/src/mandelbrot.rs @@ -26,7 +26,7 @@ impl Mandelbrot { Self::IMG_HEIGHT } - pub fn generate_image(&mut self) -> Vec { + pub fn generate_image(&mut self) -> &[u8] { self.texture_buffer .par_chunks_mut(4) .enumerate() @@ -37,7 +37,7 @@ impl Mandelbrot { buf.copy_from_slice(&Self::hsv_to_rgb(h, 0.6, 1.0)); }); - self.texture_buffer.clone() + &self.texture_buffer } pub fn generate_scaled_image(