Detect mouse clicks on Bezier curves

38 views
Skip to first unread message

Cedric

unread,
Jun 2, 2025, 8:08:39 AM6/2/25
to skia-discuss
Hello!

I'm using an SkPath to draw some Bezier curve and I have to detect when the user clicks on it. However, since the path is not closed, it's a 1 pixel width which makes it difficult to click. I wanted to increase the tolerance (to a couple of pixels around the path), so that I can detect when the user clicks close to the path.
I googled for a bit and found a potential solution here: https://github.com/unoplatform/uno/discussions/17737.

Two solutions are proposed at the bottom:
- Create a closed path which takes into account this tolerance
- Create a SkPaint with a certain stroke with and use GetFillPath

The first approach is actually not straightforward to implement, because simply offseting the curve a couple of pixels above and below the original curve will not work in all situations (e.g. if the Bezier curve is rather vertical, the center area will still be very thin).
So, I wanted to go with the second solution (which is also more elegant IMO), but to my surprise, I could not find any GetFillPath method in the C++ API for SkPaint. Is this method specific for SkiaSharp only? Or was this method moved/deleted?

Any other suggestion on how I could implement this?

Thank you,
Cédric

Florin Malita

unread,
Jun 2, 2025, 9:11:48 AM6/2/25
to skia-d...@googlegroups.com
The equivalent functionality is now in SkPathUtils.h.
 

Any other suggestion on how I could implement this?

Thank you,
Cédric

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/skia-discuss/cfee71e1-bdc4-4f40-b851-58b9cd3566acn%40googlegroups.com.

Cedric

unread,
Jun 4, 2025, 9:38:50 AM6/4/25
to skia-discuss
Oh ok, thank you! I searched for the corresponding method in the API but I did not find it since it was also renamed. Thanks for the information.
Reply all
Reply to author
Forward
0 new messages