解决canvas在手机上因缩放而产生的锯齿

http://www.zhihu.com/question/37698502

let width = canvas.width,height=canvas.height;
if (window.devicePixelRatio) {//检测是否有像素比
canvas.style.width = width + "px";
canvas.style.height = height + "px";
canvas.height = height * window.devicePixelRatio;//将canvas画布转为真实像素大小
canvas.width = width * window.devicePixelRatio;
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);//将画笔调为像素比大小
}
来解决Retina屏下的canvas锯齿问题。

原文地址:https://www.cnblogs.com/obeing/p/5291200.html