summaryrefslogtreecommitdiff
path: root/apps/web/src/services/renderer/canvas-utils.ts
blob: 6981e6d5e54dbd7ff0fa68da2e9d693d572b14e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export function createCanvasSurface({
	width,
	height,
}: {
	width: number;
	height: number;
}): {
	canvas: OffscreenCanvas;
	context: OffscreenCanvasRenderingContext2D;
} {
	const canvas = new OffscreenCanvas(width, height);
	const context = canvas.getContext("2d");
	if (!context) {
		throw new Error("Failed to create 2D rendering context");
	}
	return { canvas, context };
}