canvas模糊事件处理

不知道大家项目中有没有用到canvas时还有时候会出现模糊的情况;

具体推测可能是屏幕改变了,然而canvas的渲染对象并没有跟着一起变;

这里简单介绍个对象,window.devicePixelRatio→详细介绍http://www.zhangxinxu.com/wordpress/2012/08/window-devicepixelratio/

window.devicePixelRatio是设备上物理像素和设备独立像素(device-independent pixels (dips))的比例。
公式表示就是:window.devicePixelRatio = 物理像素 / dips

 

var scale = window.devicePixelRatio;

具体用到canvas里的时候就是所有的长度单位都要乘以这个scale变量就能解决了;

posted on 2016-08-15 22:00  求知的木头  阅读(295)  评论(0编辑  收藏  举报

导航