Use Offscreen Canvas to normalize

This commit is contained in:
Tanish Manku committed 2025-08-05 13:52:08 -07:00
1 parent 693b8c36be
commit 3fbb1ae988
1 file changed
+3 -3
@@ -1,12 +1,12 @@
export const normalizeCanvas = (canvas: HTMLCanvasElement, width: number, height: number): HTMLCanvasElement => {
const newCanvas = document.createElement("canvas");
export const normalizeCanvas = (canvas: HTMLCanvasElement, width: number, height: number): OffscreenCanvas => {
const newCanvas = new OffscreenCanvas(width, height);
newCanvas.width = width;
newCanvas.height = height;
const ctx = newCanvas.getContext("2d");
if (!ctx) {
throw new Error("Failed to get canvas context");
throw new Error("Failed to get offscreen canvas context");
}
ctx.imageSmoothingEnabled = true;