According to wikipedia: Flood fill also called Seed fill, is an algorithm that determines the area connected to a given node in a multi-dimensional array. It is used in the “bucket” fill tool of paint programs to determine which parts of a bitmap to fill with color, and in games such as Go and Minesweeper for determining which pieces are cleared. When applied on an image to fill a particular bounded area with color, it is also known as boundary fill.
I implemented it in python using pygame. The algorithm used is the depth-first algorithm(recursive). In my flood fill program, for every pixel filled, the functions analyze neighbor pixels: 4 neighbors (except diagonal neighbors); this kind of connectivity is called 4-connectivity. The code of this section is shown below:
The complete code is available in https://bitbucket.org/vidyakv/flood-fill-using-pygame/changeset/bf1a8df717ea . The following images are the snapshots taken during flood filling.