Matrix.rotate(a, x, y)

旋转矩阵。


参数
  • a 数值。表示旋转的角度。
  • x 数值。表示旋转中心点的x位置。
  • y 数值。表示旋转中心点的y位置。

返回值

元素。返回父元素。


使用
<svg id="svg" width="100" height="100"></svg>
<input id="button" type="button"  value="点击旋转45°">
var svg = Snap("#svg");
var c = svg.paper.rect(20, 20, 60, 60, 10).attr({
    fill: "#f00"    // 红色
});

var rot = 0;
document.getElementById("button").onclick = function() {
    Snap.animate(rot, rot + 45, function(value) {
        rot = value;
        // 旋转
        c.transform(new Snap.Matrix().rotate(value, 50, 50));
    }, 500);
};