如何将Microsoft.Matrix过滤器与画布旋转相等?

时间:2008-12-14 13:27:56

标签: javascript image html5 canvas rotation

有没有人能够帮助这个通用旋转功能(它适用于jquery,但这是一个javascript的事情):http://pastebin.com/m382b30e

我更改了非IE画布代码,因此它将围绕图像的中心旋转(请参阅firefox中的http://uptowar.com/jquery)。现在我需要更改IE microsoft过滤器以执行相同操作(请参阅Internet Explorer中的相同URL)。但是,怎么样?该过滤器的文档很难理解。

1 个答案:

答案 0 :(得分:1)

假设您有一个以弧度给出的角度nAngle,旋转矩阵将如下所示:

var nCos    = Math.cos(nAngle).toFixed(3),
    nSin    = Math.sin(nAngle).toFixed(3);

var sFilter = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=" + nCos + ", M12=" + (-nSin) + ", M21=" + nSin + ", M22=" + nCos + ")";

您可能还需要查看规范:Matrix Filter