1function createCanvas(width, height, set2dTransform = true) {
2 const ratio = Math.ceil(window.devicePixelRatio);
3 const canvas = document.createElement('canvas');
4 canvas.width = width * ratio;
5 canvas.height = height * ratio;
6 canvas.style.width = `${width}px`;
7 canvas.style.height = `${height}px`;
8 if (set2dTransform) {
9 canvas.getContext('2d').setTransform(ratio, 0, 0, ratio, 0, 0);
10 }
11 return canvas;
12}
13