Wave algorithm
This algorithm assigns a new color to the points of a 4-contiguous area if the given point complies with the condition that it is inside of the area being filled.
Wave algorithm filling:
void Filling (int x,int y,Color old_color,Color new_color)
{
if (read_pixel (x,y) == old_color) // pixel color test
{
write_pixel
(x, y, new_color); // paints the pixel in a new color
Filling
(x, y-1, old_color, new_color);
Filling
(x, y+1, old_color, new_color);
Filling
(x-1, y, old_color, new_color);
Filling
(x+1, y, old_color, new_color);
}
}