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

SVGPathCommander.transform() return the path that has 'NaN' #6

Closed jglee96 closed 2 years ago

jglee96 commented 2 years ago

Hello, I try to transfrom SVG path. my code is like this,

const path = new SVGPathCommander(svgPath, {});
const pathMatrix: SVGPathCommander.transformObject = {
  translate: [x, y],
  rotate: angle,
  origin: [0, 0],
};
path.transform(pathMatrix);

The path has NaN position value. I found that the function projection2D(m, point2D, origin) divide number by 0 when originZ is 0. I think it cause NaN value. When I use random number on z value of origin like this origin: [0, 0, {random number}], it doesn't make NaN

thednp commented 2 years ago

Thanks for the report, I forgot to have it handle 2 values origin. Stay tuned.

thednp commented 2 years ago

@jglee96 please test latest master and let me know ;)

jglee96 commented 2 years ago

It works! Thank you for fixing it quickly!