In WPF, when you draw for ex. circle using Path and set thick StorkeThickness, you are able to generate a new PathGeometry which contains is their segments also stroke (check MSDN).
Having this PathGeometry you are able to check if hit (touched) point belong to specified Path (check MSDN), and it works only for those places where this path is painted.
I would like to do this exactly in similar way in SkiaSharp.
When I touch canvas, I am able to detect proper SKPath (SKPath.Contains(x, y)) but this function relay on Rect, so when I have for example Circle and touch inside Circle, SKPath.Contains returns true.
How to achieve similar effect in SkiaSharp like in WPF ?
If I understand what GetFlattenedPathGeometry does, this might be what you are looking for: https://docs.microsoft.com/dotnet/api/skiasharp.skpaint.getfillpath
Currently, I finish working on this.
I draw a newPath taken from GetFillPath and check if pixel color in touched/clicked location has the same color like color of my original path (original path has always one color).
Having this function I was able also to detect the real beginning of drawn path for ex. you have triangle with thick StrokeThickness. Original SKPath doesn't include points where border begins but filled Path contains them.
I wanted to avoid drawing of this additional SKPath to detect the real edge of SKPath.
I thought that maybe there is some complex algorithm (based on interpolation) to check if a clicked point is inside SKPath without drawing this SKPath (at the end it is a set of figures in the cartesian system).
Anyway, thank you for pointing me a right direction.
Most helpful comment
If I understand what
GetFlattenedPathGeometrydoes, this might be what you are looking for: https://docs.microsoft.com/dotnet/api/skiasharp.skpaint.getfillpath