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

Import with fromSVGPathData breaks circle/arc. #499

Open
NielsdeBlaauw opened this issue May 20, 2021 · 0 comments
Open

Import with fromSVGPathData breaks circle/arc. #499

NielsdeBlaauw opened this issue May 20, 2021 · 0 comments
Labels

Comments

@NielsdeBlaauw
Copy link

NielsdeBlaauw commented May 20, 2021

What is happening

When using fromSVGPathData to generate a model from the string M77.497 2.497a75 75 0 0 1 0 150 75 75 0 0 1 0-150z, makerJS incorrectly imports the shape as a half-circle. It produces the following pathdata:

{ paths:
       { p_1:
          Arc {
            radius: 75,
            origin: [Array],
            startAngle: 270,
            endAngle: 450,
            type: 'arc' },
         p_2: Line { type: 'line', origin: [Array], end: [Array] } } }

When exported to DXF this shows:
Screenshot from 2021-05-20 13-36-54

What is expected

In the browser (tested on chrome, firefox, latest), the PathData M77.497 2.497a75 75 0 0 1 0 150 75 75 0 0 1 0-150z produces a full circle:

Screenshot from 2021-05-20 13-29-02

Also, adding an extra a in the PathData string results in the same shape in the browser, and a correct full circle model in MakerJS:

Bad:  M77.497 2.497a75 75 0 0 1 0 150 75 75 0 0 1 0-150z
Good: M77.497 2.497a75 75 0 0 1 0 150 a 75 75 0 0 1 0-150z

MakerJS converts the pathData with the extra a to a model correctly:

{ paths:
       { p_1:
          Arc {
            radius: 75,
            origin: [Array],
            startAngle: 270,
            endAngle: 450,
            type: 'arc' },
         p_2:
          Arc {
            radius: 75,
            origin: [Array],
            startAngle: 90,
            endAngle: 270,
            type: 'arc' } } }

Samples

bad.svg.txt
good.svg.txt

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

No branches or pull requests

2 participants