feat(renderer): draw selection overlay

This commit is contained in:
syntaxbullet
2026-07-03 16:04:43 +02:00
parent 28fcbdceda
commit 4d77288450
4 changed files with 43 additions and 11 deletions

12
renderer/screen-rect.ts Normal file
View File

@@ -0,0 +1,12 @@
import type { Rect } from "@core/geometry";
import type { ViewportState } from "@editor/state";
import type { ScreenRect } from "./types";
export function documentRectToScreenRect(canvas: HTMLCanvasElement, rect: Rect, viewport: ViewportState): ScreenRect {
return {
x: Math.round(canvas.width / 2 + (rect.x - viewport.center.x) * viewport.zoom),
y: Math.round(canvas.height / 2 + (rect.y - viewport.center.y) * viewport.zoom),
w: Math.max(0, Math.round(rect.w * viewport.zoom)),
h: Math.max(0, Math.round(rect.h * viewport.zoom)),
};
}