Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rect: fix bounds #717

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading