Skip to content

Commit

Permalink
Merge pull request #717 from JerwuQu/jwq_rect-bounds
Browse files Browse the repository at this point in the history
rect: fix bounds
  • Loading branch information
aduros authored May 23, 2024
2 parents ff4d97f + 82e4dcd commit f7b5360
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 f7b5360

Please sign in to comment.