图片旋转js代码


function rotateImage(imgId) {

imageToRotate = document.getElementById(imgId);   

imageToRotate.style.filter= "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";

rotate();

}

var imageToRotate;

var degreeToRotate=0;

function rotate(){

var deg2radians = Math.PI * 180 / 360;

degreeToRotate++;

degreeToRotate=degreeToRotate%360;   

rad = degreeToRotate * deg2radians ;

costheta = Math.cos(rad);

sintheta = Math.sin(rad);

imageToRotate.filters.item(0).M11 = costheta;

imageToRotate.filters.item(0).M12 = -sintheta;

imageToRotate.filters.item(0).M21 = sintheta;

imageToRotate.filters.item(0).M22 = costheta;  

 

}

 

 

参数传图片的id即可,比较简单,使用的是IE滤镜


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM