Closed leonbohmann closed 2 years ago
You can do this:
var pathMeasure = new SKPathMeasure(path);
float length = pathMeasure.Length;
float side = length / 4f;
float area = side * side;
Sure, but that is only valid for rectangles. What if I add a beziers?
In theory, it should work with any curves. Need to test with closed curves.
See below picture. There, I don't even have 4 'sides'. I can't calculate that using (side)², can I?
Of course I need some kind of abbreviation since a bezier can't be integrated easily. What I could do is using triangles to approximate curves.
We just interpret the length of the curve as a square, that's all.
Yes, I was wrong, the algorithm is somewhat more complicated. you need to split the curve into polygons and calculate their total area.
You can try using SKRegion with CreateRectIterator...
That is an awesome idea! I tried it with SkiaSharpFiddle: I will iterate over the rectangles and calculate their area and just sum it up.
Thanks a lot!
After searching the web for quite some time now, I can't find appropriate answers, for which the questions are quite simple:
a) Is there a method to calculate the area of an SKPath? b) Is there a way I can iterate through the SKPath and calculate the area on my own? With Gauss, maybe?