简体   繁体   中英

Convert rotation to points array for a SVG Path

I have a path that is basically a rectangle with 4 points. I rotate it by adding 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.

Please advise.

You can convert a path string by using the Snap.path.map() method. 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 ); and it should convert it for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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