Function: updateCanvasSizeAndAspectRatio()
updateCanvasSizeAndAspectRatio(
canvas,extentOrOffscreen?):boolean|undefined
Updates an on-screen viewport canvas size and aspect ratio so it fills correctly and resizes without flicker. Handles two cases:
-
No extent/offscreen: size from the canvas's displayed rect (e.g. when enabling viewports or after layout change). Returns undefined.
-
Extent or offscreen canvas provided: size to match the rendered extent. Returns true if the canvas was updated (caller should redraw), false if it already matched.
Parameters
• canvas: HTMLCanvasElement
The on-screen canvas to update.
• extentOrOffscreen?: ViewportCanvasExtent
Optional. When an HTMLCanvasElement, use its width/height as the target extent. When an object with width and height (e.g. viewport sWidth/sHeight when the offscreen canvas is shared), use that.
Returns
boolean | undefined
undefined when no extent/offscreen (element-rect update); true when canvas was updated (rendering/redraw needed); false when canvas already matched the extent.
Defined in
packages/core/src/RenderingEngine/helpers/getOrCreateCanvas.ts:94