You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like, when using the Path.getPositionAtLength function the incorrect position is returned for some lengths. This seems to be happening around curvatures.
Example: Take this SVG Path
m 1633.8176,1077.4212 c 0,0 18.4277,-511.56464 -14.7423,-535.31585 -32.2488,-23.0917 -318.7995,-9.13506 -318.7995,-9.13506 H 830.3691 c 0,0 -182.43438,-54.81052 -189.80546,-129.7182 -3.97298,-40.37463 -16.58496,-164.43147 -16.58496,-164.43147 0,0 -60.81148,-89.5238 -180.59162,-95.00485 C 323.6069,138.33472 -4.4064367,134.68069 -4.4064367,134.68069")
And now following positions
let p0 = p.getPointAtLength(87.9549) //black
let p1 = p.getPointAtLength(91.9549) //red - incorrect
let p2 = p.getPointAtLength(94.8549) //green
let p3 = p.getPointAtLength(97.7549) //blue
When drawing circles at these points (using the annotated colours) I get the following picture
As you can see, the Red dot is above the green dot whereas the order should be in the same order as the Length along the path, i.e.:
black, red, green, blue
The text was updated successfully, but these errors were encountered:
I have found issues with path measuring in Konva before. The math is pretty tricky and it is possibly a slightly old part of the library that was never correct since original. The easy workaround is to make yourself a function that instantiates an HTL SVG element and use the getPointAtLength function of the SVG object. You don't need to add the SVG element to the page.
Granted this is not a solution and it would be great if Konva was correct, but its a viable right-now workaround with low overhead.
I would prefer a native solution as much as possible where possible, to have less code in Konva and better solution from the platform.
But, we have a case when we run Konva from node.js. And it doesn't have HTML svg. As workaround, we can do similar to image loading. It means we will have a special function to calculate svg path, so we can easily overwrite such function in node.js with some plain code (or external library).
It looks like, when using the
Path.getPositionAtLength
function the incorrect position is returned for some lengths. This seems to be happening around curvatures.Example: Take this SVG Path
And now following positions
When drawing circles at these points (using the annotated colours) I get the following picture
As you can see, the Red dot is above the green dot whereas the order should be in the same order as the Length along the path, i.e.:
black, red, green, blue
The text was updated successfully, but these errors were encountered: