Too Long; Didn't Read
The “Bucket” tool of Microsoft Paint is used to fill an area with single specific color. We are going to discuss the algorithm behind the bucket tool. We will solve this problem using a Recursive Function. The idea is simple. At first we replace the color of current pixel and then we will go in 8 directions(N, S, W, E, NW, NE, SW, SE) and convert all the previous color values into the new color values. Then we will get the image with new color. The following is the implementation of the Flood Fill Algorithm.