Matrix.add(…)

给现有矩阵再添加一个矩阵。


参数

或者

  • matrix 对象。矩阵对象。

返回值

对象。元素。


使用
<svg id="svg" width="100" height="100"></svg>
<input type="button" id="button"  value="点击执行add()">
var svg = Snap("#svg");
// 画个圈圈
var c = svg.paper.circle(50, 50, 20);
// 当前矩阵
var m1 = new Snap.Matrix(1,0,0,1,20,20);
// 圈圈应用矩阵变换 - 位移(20, 20)
c.transform(m1.toTransformString());

// 事件
if (document.addEventListener) {
    document.querySelector("#button").addEventListener("click", function() {
        // 矩阵组合
        m1.add(1,0,0,1,-10,-10);
        // 圈圈再次应用矩阵变换 - 位移(-20, -20)
        c.transform(m1.toTransformString());
    });
}