I need to fill the color inside custom shape. I know one of the pixel coordinate inside the shape and also know the color of the shape. I need to get all pixel inside the shape calculate from knowing pixel coordinate how can i write logic for this can some one please help.
Asked
Active
Viewed 793 times
1 Answers
0
For already rendered shapes
use Flood Fill or Boundary fill algorithms. For example see:
beware most implementations are recursive so there is a high risk of stack/heap overflow for bigger areas. There are also iterative approaches using dynamic point lists which are safer.
For polygons in vector form
Use convex polygon filling. In case you got concave polygons you need to divide them into convex polygons first. Another options is to triangulate. Both triangle and convex polygon rasterization is the same see:
If you need triangulation see:
In case of very complicated shapes and not possible triangulation for any reason you can try fill all the pixels in the bounding box of polygon that are inside polygon. For that you need: