From ba5d791a32a572b6bf2c6ed59f595c300c5fc584 Mon Sep 17 00:00:00 2001 From: Marcus Ramse Date: Mon, 13 May 2024 13:26:18 +0000 Subject: [PATCH] sim: fix rect boundscheck --- simulator/src/framebuffer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simulator/src/framebuffer.ts b/simulator/src/framebuffer.ts index a6c68dc..3eaa169 100644 --- a/simulator/src/framebuffer.ts +++ b/simulator/src/framebuffer.ts @@ -72,8 +72,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)); if (fillColor !== OPTIONAL_COLOR_NONE) { for (let yy = startY; yy < endY; ++yy) {