Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path2Curve produces wrong result when converting L command #17

Closed
xiaoiver opened this issue Jun 21, 2022 · 8 comments
Closed

path2Curve produces wrong result when converting L command #17

xiaoiver opened this issue Jun 21, 2022 · 8 comments

Comments

@xiaoiver
Copy link

xiaoiver commented Jun 21, 2022

Path for testing:

M57.063 -18.541L13.225 -18.203L0 -60L-13.225 -18.203L-57.063 -18.541L-21.399 6.953L-35.267 48.541L0 22.5L35.267 48.541L21.399 6.953Z

after toCurve, I changed some CSS style:

fill: none;
stroke: red;

截屏2022-06-21 下午3 04 24

@thednp
Copy link
Owner

thednp commented Jun 21, 2022

Thanks for the report, I believe this must be related to the latest optimizations, but will look into it asap.

@xiaoiver
Copy link
Author

xiaoiver commented Jun 21, 2022

Thanks for the report, I believe this must be related to the latest optimizations, but will look into it asap.

Thanks, I think the problem came from the following lines which calculate control points of cubic bezier:
https://github.com/thednp/svg-path-commander/blob/master/src/process/lineToCubic.js#L24-L29

@thednp
Copy link
Owner

thednp commented Jun 21, 2022

Exactly.

thednp added a commit that referenced this issue Jun 21, 2022
@thednp
Copy link
Owner

thednp commented Jun 21, 2022

@xiaoiver please test latest master, it's solved for me.

@thednp
Copy link
Owner

thednp commented Jun 21, 2022

@xiaoiver can you please confirm the fix? We're ready to push the next v1.0.5 now.

@xiaoiver
Copy link
Author

@xiaoiver can you please confirm the fix? We're ready to push the next v1.0.5 now.

I found another bug about converting A command to C, this is my test path:

M7.34788079488412e-15,-120A120,120,0,0,1,95.46267154065043,-72.71092312934756L59.66416971290652,-45.44432695584223A75,75,0,0,0,4.592425496802574e-15,-75Z

It should look like this:

截屏2022-06-21 下午11 01 03

But after converting to curve, it became this:

截屏2022-06-21 下午11 01 53

@thednp
Copy link
Owner

thednp commented Jun 21, 2022

I found the problem, it's the arcToCubic that's messing things up, also an issue introduced with the ES5->ES6 changes.

Will come back with a fix asap. Stay tuned.

thednp added a commit that referenced this issue Jun 21, 2022
@thednp
Copy link
Owner

thednp commented Jun 21, 2022

@xiaoiver please test. Now this works for me

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants