最近在使用flashcanvas来解决ie等不支持HTML5 canvas的问题,我做的是个画笔工具,当用户把浏览器缩放为75%时,画出的图形居然错位了,我把坐标的值*0.75传进去就ok了
以下是计算当前浏览器缩放比例的方法
经过我的测试发现,如果在浏览器比例缩小的情况下,我们使用flashcanvas绘图的话,传递给flash内部的坐标参数
以下是计算当前浏览器缩放比例的方法
detectZoom:function(){
var ratio=0,
screen=window.screen,
ua=navigator.userAgent.toLowerCase();
if(ua.indexOf('firefox') > -1){
if(window.devicePixelRatio!==undefined){
ratio=window.devicePixelRatio;
}
}else if(ua.indexOf('msie') > -1){
if(screen.deviceXDPI&&screen.logicalXDPI){
ratio=screen.deviceXDPI/screen.logicalXDPI;
}
}else if(window.outerWidth!==undefined&&window.innerWidth!==undefined){
ratio=window.outerWidth/window.innerWidth;
}
return ratio;
}
经过我的测试发现,如果在浏览器比例缩小的情况下,我们使用flashcanvas绘图的话,传递给flash内部的坐标参数