JS SVG getCTM and setCTM?

后端 未结 2 853
离开以前
离开以前 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));
    }
    
    0 讨论(0)
  • 2021-02-02 02:21
    var transform = ownerSVGElement.createSVGTransform()
    
    transform.setMatrix(elem.getCTM())
    
    someelement.transform.baseVal.initialize(transform)
    
    0 讨论(0)
提交回复
热议问题