-
Notifications
You must be signed in to change notification settings - Fork 266
Open
Description
I'm using twgl to create backgrounds for pages, on very large displays this can cause the canvas to become huge, tanking performance.
I've patched the project locally to introduce maxWidth
and maxHeight
arguments for the resizeCanvasToDisplaySize
and let CSS stretch the canvas the rest of the way should the display size be large.
function resizeCanvasToDisplaySize(canvas, multiplier, maxWidth, maxHeight) {
multiplier = multiplier || 1;
multiplier = Math.max(0, multiplier);
var width = Math.min(canvas.clientWidth * multiplier | 0, maxWidth);
var height = Math.min(canvas.clientHeight * multiplier | 0, maxHeight);
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
return true;
}
return false;
}
Metadata
Metadata
Assignees
Labels
No labels