JS SVG getCTM and setCTM?

后端 未结 2 852
离开以前
离开以前 2021-02-02 02:00

If I use getCTM() to get the current tranformation matrix, how do I use that object to set the matrix if I want to restore it at a later point (I know about save and restore but

2条回答
  •  花落未央
    2021-02-02 02:09

    function setCTM(someitem,m) {
      return someitem.transform.baseVal.initialize(
        someitem.ownerSVGElement.createSVGTransformFromMatrix(m));
    }
    

    If, instead of saving someItem.getCTM(), you save someitem.transform.baseVal.getitem(0), you can use:

    function setTransform(someitem,t) {
      return someitem.transform.baseVal.initialize(t));
    }
    

提交回复
热议问题