如何从变换字符串中获取x,y和缩放x,y的比例,它是translate(123,343.32) scale(0.8,0.89)
答案 0 :(得分:1)
SVG带有DOM API,可以获取这些值...
var g = document.getElementById("g");
console.log(g.transform.animVal[0].matrix.e + ", " + g.transform.animVal[0].matrix.f);
console.log(g.transform.animVal[1].matrix.a + ", " + g.transform.animVal[1].matrix.d);
<svg>
<g id="g" transform="translate(123,343.32) scale(0.8,0.89)"/>
</svg>