手记

canvas 显示模糊问题

//=== canvas 模糊问题 start
            var ratio = getPixelRatio(ct);
            if(ratio == 1) { // PC端 PixelRatio
                ratio = 2;
            }
            cs.style.width = cs.width + 'px';
            cs.style.height = cs.height + 'px';
            cs.width = cs.width * ratio;
            cs.height = cs.height * ratio;
            ct.scale(ratio, ratio);
            //=== canvas 模糊问题 end

var getPixelRatio = function (context) {
            var backingStore = context.backingStorePixelRatio ||
                context.webkitBackingStorePixelRatio ||
                context.mozBackingStorePixelRatio ||
                context.msBackingStorePixelRatio ||
                context.oBackingStorePixelRatio ||
                context.backingStorePixelRatio || 1;
            return (window.devicePixelRatio || 1) / backingStore;
        };
0人推荐
随时随地看视频
慕课网APP