圖片旋轉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