diff options
Diffstat (limited to 'evc/src/frame.rs')
-rw-r--r-- | evc/src/frame.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/evc/src/frame.rs b/evc/src/frame.rs index 81fdf3b..78d0e73 100644 --- a/evc/src/frame.rs +++ b/evc/src/frame.rs @@ -63,11 +63,8 @@ impl Index<Vec2<isize>> for Frame { type Output = Pixel; #[inline] fn index(&self, Vec2 { x, y }: Vec2<isize>) -> &Self::Output { - if x >= 0 && y >= 0 && x < self.size.x && y < self.size.y { - &self.buffer[(x + y * self.size.x) as usize] - } else { - &Pixel::BLACK - } + &self.buffer + [(x.clamp(0, self.size.x - 1) + y.clamp(0, self.size.y - 1) * self.size.x) as usize] } } impl IndexMut<Vec2<isize>> for Frame { |