chore: change return type of Mandelbrot::generate_image()

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-02-22 18:49:10 -06:00
parent 61414cf744
commit 1ce54d5b5a
2 changed files with 3 additions and 3 deletions

View File

@ -109,7 +109,7 @@ fn startup(
mut materials: ResMut<Assets<ColorMaterial>>,
) {
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,

View File

@ -26,7 +26,7 @@ impl Mandelbrot {
Self::IMG_HEIGHT
}
pub fn generate_image(&mut self) -> Vec<u8> {
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(