Open Calsign opened 1 month ago
Thanks for the bug report @Calsign.
The algorithms in bézier-rs aren't particularly robust or performant. The original maintainers of the library implemented it as a university project and are no longer working on it. Therefore it is only maintained or improved if it is required for the Graphite editor.
If it would be useful I think @Keavon could probably create a new release with reasonable ease.
Hi, could you provide an example document where this is visible to the naked eye? I am working on this and would like to have visual confirmation if it works :)
In the current released version of bezier-rs, 0.4.0, the logic for approximating
Bezier::euclidean_to_parametric
is wrong. Specifically here:This logic is supposed to use more subidivions the closer we are to 0.5. Instead, it uses only one subdivision at 0.5 and uses the most subdivisions near 0 and 1 where they aren't necessary. The consequence is that the approximation gets increasingly imprecise near 0.5. Additionally, since it picks which direction to estimate from based on which side of 0.5 it's on, there's a big discontinuity at 0.5 as it switches across two bad approximations.
I noticed this when I found some sample beziers that exhibited this sharp discontinuity at 0.5. It only seems to be noticeable for some beziers, I haven't figured out why. This test demonstrates that behavior:
Output:
Fortunately, this logic has changed completely in https://github.com/GraphiteEditor/Graphite/pull/1624, specifically https://github.com/GraphiteEditor/Graphite/commit/218e9675fd2751ac588a8a6995ec045e00539fcb. I am working around this by using the latest master version of bezier-rs.
I didn't see an existing issue for this so I thought it was worth posting in case others encounter the same issue. Also, a new release of bezier-rs with the refactor/fix would be appreciated.