图片旋转js代码
时间:2014-07-22 23:14:36
收藏:0
阅读:386
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;
}
评论(0)