码迷,mamicode.com
首页 > Web开发 > 详细

图片旋转js代码

时间:2014-09-19 16:56:55      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:style   io   os   java   ar   for   sp   cti   代码   

<script type="text/javascript">
//图片旋转js代码(2013-5-27)
        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;
            alert(deg2radians);
            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;
        }

    </script>

图片旋转js代码

标签:style   io   os   java   ar   for   sp   cti   代码   

原文地址:http://www.cnblogs.com/XIAO-BAI/p/3981530.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!