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

elliptic Arc commands: getPointAtLength() returns unexpected value #66

Open
herrstrietzel opened this issue Aug 8, 2023 · 0 comments
Open

Comments

@herrstrietzel
Copy link

herrstrietzel commented Aug 8, 2023

Thanks for this great library!

Not sure if I've missed a point:
but it seems like svg-path-properties version of getPointAtLength() has issues with elliptical A arc commands.

A path data d value of M 50 0 a 50 30 22 0 1 50 75 would return midpoint (pathlength/2) coordinates using the native getPointAtLength()

{x:115.578, y:24.136}

but it returns using svg-path-properties

{x: 122.625, y:32.651}

See this codepen example.
(This example compares the native method against svg-path-properties equivalent.)

As a clunky (but working) workaround I converted elliptical arctos to cubic bézier approximations:

In my "post-processing" fix I also "re-parse" and normalize the current pathData, which should be obsolete since the lib already does this on initial parsing (but I wasn't smart enough to understand the original code)

  • check if we have any relative commands => convert to absolute
  • convert shorthand commands to their longhand equivalents

Is there an easier way to solve this issue?

@herrstrietzel herrstrietzel changed the title elliptic arcTo commands: getPointAtLength() returns unexpected value elliptic Arc commands: getPointAtLength() returns unexpected value Aug 8, 2023
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

1 participant