image-js
image-js copied to clipboard
Enhance `filled` option in `drawPolygon`
Enhance the performance of the fill in drawPolygon by running robustPointInPolygon only when it's strictly necessary.
We might first draw the contour of the polygon on a mask, and at every pixel, verify if the previous value and the current value are equal. If it is the case, the value of robustPointInPolygon should be the same as for the previous pixel.
A better way of enhancing performance would be:
- Draw the contour first
- Find one point inside of the polygon
- Make a
floodFillusing the previous point as a starting point