Skip to content

Commit

Permalink
rect: fix bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
JerwuQu committed May 13, 2024
1 parent 0dff7ad commit 82e4dcd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions runtimes/native/src/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ void w4_framebufferRect (int x, int y, int width, int height) {
int startY = w4_max(0, y);
int endXUnclamped = x + width;
int endYUnclamped = y + height;
int endX = w4_min(endXUnclamped, WIDTH);
int endY = w4_min(endYUnclamped, HEIGHT);
int endX = w4_max(0, w4_min(endXUnclamped, WIDTH));
int endY = w4_max(0, w4_min(endYUnclamped, HEIGHT));

uint8_t dc01 = drawColors[0];
uint8_t dc0 = dc01 & 0xf;
Expand Down
4 changes: 2 additions & 2 deletions runtimes/web/src/framebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export class Framebuffer {
const startY = Math.max(0, y);
const endXUnclamped = x + width;
const endYUnclamped = y + height;
const endX = Math.min(endXUnclamped, WIDTH);
const endY = Math.min(endYUnclamped, HEIGHT);
const endX = Math.max(0, Math.min(endXUnclamped, WIDTH));
const endY = Math.max(0, Math.min(endYUnclamped, HEIGHT));

const drawColors = this.drawColors[0];
const dc0 = drawColors & 0xf;
Expand Down

0 comments on commit 82e4dcd

Please sign in to comment.