Skip to content

Commit

Permalink
Implement ImageBuffer::add_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Oom committed Mar 26, 2024
1 parent fffa680 commit a66b45f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/image_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit a66b45f

Please sign in to comment.