|
|
|
|
|
by CrimsonCape
803 days ago
|
|
The OP had perfect timing as I was scratching my head on how to implement click hit-testing a bezier. Flattening and then hit testing the segments in parallel is exactly what I was looking for, as it should be fast and I already implemented hit-testing line segments with stroke/margin-of-error expansion. Aside from seeming like a good solution, would you go that route? |
|
What kurbo does is lower to quadratic Béziers[1], then the analytic solution to nearest for a quadratic Bézier is the solution to a cubic equation[2].
I'm not sure this is the best possible answer, but it's at least pretty good, and certainly better than flattening to lines.
And I'd like for people to get in the habit of checking kurbo; the intent is for it to always have the best in class algorithm.
[1]: https://docs.rs/kurbo/latest/src/kurbo/cubicbez.rs.html#647-...
[2]: https://docs.rs/kurbo/latest/src/kurbo/quadbez.rs.html#297-3...