thednp / svg-path-commander

Typescript tools for advanced processing of SVG path data.
https://thednp.github.io/svg-path-commander/
MIT License
222 stars 19 forks source link

Scale transform doesn't take into consideration the origin property #23

Closed lordanubi closed 1 year ago

lordanubi commented 1 year ago

Hi, I noticed these transformations take into consideration the origin:

if (flipY) pathCommander.transform({ rotate: [180, 0, 0], origin: groupCenter });
if (rotate) pathCommander.transform({ rotate, origin: groupCenter });

while this will still scale the path based on its own center instead of the given origin if (scale) pathCommander.transform({ scale, origin: groupCenter });

Why is that?

thednp commented 1 year ago

What is groupCenter?

lordanubi commented 1 year ago

It is obtained by merging the d attributes of all the paths we want to apply the transform, getting the viewbox of the unified path and than it is obtained with [bbox.cx,bbox.cy]

thednp commented 1 year ago

I want to see some code sample.

lordanubi commented 1 year ago

https://jsfiddle.net/Scanu/3fdLut4m/40/ Just made up a little fiddle to show the problem and i just realised that it is actually working as expected. Will look further in my codebase to see what's going wrong. thank you very much for your help!

lordanubi commented 1 year ago

ok found the error in the rest of my code, will close the issue. thank you again for this wonderful tool! Have a nice day :)