简体   繁体   English

将旋转转换为SVG路径的点阵列

[英]Convert rotation to points array for a SVG Path

I have a path that is basically a rectangle with 4 points. 我有一条基本上是4点的矩形的路径。 I rotate it by adding transform="rotate(45)" . 我通过添加transform="rotate(45)"旋转它。 Now I need to get coords of each corner point of the rotated path relatively to the container. 现在,我需要获取相对于容器的旋转路径的每个角点的坐标。

Probably it should be not rotation at all, but calculating a new d value with some algorithm for the path then setting it and making path look like it was rotated. 可能根本就不是旋转,而是使用某种算法为路径计算新的d值,然后对其进行设置并使其看起来像是旋转的。

Please advise. 请指教。

You can convert a path string by using the Snap.path.map() method. 您可以使用Snap.path.map()方法转换路径字符串。 Docs . 文件

So using a matrix (eg Snap.matrix().rotate(45)), you can then pass it along with your path string to the Snap.path.map( myPath, myMatrix ); 因此,使用矩阵(例如Snap.matrix()。rotate(45)),然后可以将其与路径字符串一起传递到Snap.path.map(myPath,myMatrix); and it should convert it for you. 它应该为您转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM