📅  最后修改于: 2022-03-11 15:02:56.432000             🧑  作者: Mango
function createCanvas(width, height, set2dTransform = true) {
const ratio = Math.ceil(window.devicePixelRatio);
const canvas = document.createElement('canvas');
canvas.width = width * ratio;
canvas.height = height * ratio;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
if (set2dTransform) {
canvas.getContext('2d').setTransform(ratio, 0, 0, ratio, 0, 0);
}
return canvas;
}