If we have a specified boundary in a single color, then the fill algorithm proceeds pixel by pixel until the boundary color is encountered. If you press the right mouse button, it'll floodFill at that position with a color defined by the coordinates of that position.
Each seed gives the pixel at its position the new color, and then plants a new seed at its 4 neighbors. If the color of the node to the south of n is target-color, add that node to the end of Q. It's the Bucket Tool in many painting programs.
In this, generally two methods are given that are: 4-connected: In this firstly there is a selection of the interior pixel which is inside the boundary then in reference to that pixel, the adjacent pixel will be filled up that is top-bottom and left-right.
Adapting the algorithm to use an additional array to store the shape of the region allows generalization to cover "fuzzy" flood filling, where an element can differ by up to a specified threshold from the source symbol. Move e to the east until the color of the node to the east of e no longer matches target-color.
That one isn't drawn yet, and if it isn't an edge, the algorithm will continue there, testing to the right again, and so on The mouse will discover new walls and call the solver again as needed. A returned value of indicates an error.
Set w and e equal to n.
This method is called the boundary-fill algorithm. The state of map on entry is not important and it is not important whether all the walls have been found. Set Q to the empty queue.