09. Filled Area Primitives - 2
Dated: 12-05-2025
Boundary Fill
We can find paint-scan function
in common interactive paint packages.
Idea is to have a closed figure
, then selecting a point
within the figure
with a color
to fill.
The algorithm requires has parameters:
Coordinates
of startingpoint
- Fill
color
Color
of boundary
Algorithm
- Check the
pixel
for boundarycolor
- Check the
pixel
for fillcolor
- Set the
pixel
in fillcolor
- Run the process for neighbors
Flood Fill
Sometimes, we may want to replace the color
of all connected pixels
.
For this case, we just need something like if(getPixel(x, y).color == oldColor)
.
Neighbors
Algorithm with 4 neighbors.