Closed bojue closed 3 years ago
canvas的dpr兼容原理
var ctx = canvas.getContext('2d');
var dpr = window.devicePixelRatio || window.webkitDevicePixelRatio || window.mozDevicePixelRatio || 1;
var w = canvas.width;
var h = canvas.height;
canvas.width = Math.round(w * dpr);
canvas.height = Math.round(h * dpr);
canvas.style.width = w + 'px';
canvas.style.height = h + 'px';
ctx.scale(dpr, dpr);
现在是通过mac/window操作系统设置canvas屏幕缩放比例