From a66b45f6c2f07a4fbaba567e170d594956e4c82d Mon Sep 17 00:00:00 2001 From: Daniel Oom Date: Tue, 26 Mar 2024 21:53:24 +0100 Subject: [PATCH] Implement ImageBuffer::add_mut --- src/image_buffer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/image_buffer.rs b/src/image_buffer.rs index 506c0918..3690b7c1 100644 --- a/src/image_buffer.rs +++ b/src/image_buffer.rs @@ -49,6 +49,13 @@ impl ImageBuffer { ) } + pub fn add_mut(&mut self, rhs: Self) { + self.0 + .iter_mut() + .zip(rhs.0.iter()) + .for_each(|(a, b)| *a += *b) + } + pub fn add_pixel_mut(&mut self, x: u32, y: u32, value: [f32; 3]) { self.0[(x, y)][0] += value[0]; self.0[(x, y)][1] += value[1];