mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 17:52:20 +00:00
fix(eficore): don't panic when filling a rectangle past the right edge
The slice start was after its end when the rectangle began beyond the framebuffer width, which happens when the cursor is at the right edge.
This commit is contained in:
1 parent
7d913b3ab4
commit
de2df4a183
1 file changed
+4
-1
@@ -46,8 +46,11 @@ impl Framebuffer {
|
||||
pub fn fill_rect(&mut self, x: usize, y: usize, width: usize, height: usize, color: BltPixel) {
|
||||
let end_x = x.saturating_add(width).min(self.width);
|
||||
let end_y = y.saturating_add(height).min(self.height);
|
||||
if x >= end_x {
|
||||
return;
|
||||
}
|
||||
for row in y..end_y {
|
||||
// The row is in bounds, so its range is within the pixels.
|
||||
// The row and columns are in bounds, so its range is within the pixels.
|
||||
self.pixels[row * self.width + x..row * self.width + end_x].fill(color);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user