The paint bucket is a tool in various drawing programs that is used to fill areas of an image that contain the same (or similar) color with a new color. The tool allows the user to select a region by clicking on the image. The pixel where the user clicks is changed to the new color. All pixels that are the same color and that border the pixel that the user clicks (excluding pixels that are diagonal) are changed to the new color. Then each of the pixels that were changed to a new color change the color of the pixels that border to them... etc. You can see how this is a recursive procedure.
The file DrawShapes.java contains the drawing program that we created in class earlier in the semester. Add a fill tool to this program. The fill tool should be selected in the same combo box that is used for selecting shapes. When the user clicks on the drawing area while the fill tool is selected all of the pixels that boarder the click location and are the same color should be colored with the currently selected color. You should use recursion to implement this behavior.
The program has been modified slightly to draw to an image instead of a graphics object. It is possible to determine the color of any pixel in the image using the getRGB method of the BufferedImage class. Notice how the program draws to the image by first creating a Graphics object from the image. You will need to do this in order to draw pixels to the image. Pixels can be drawn as they have been in the previous two post labs, by filling a 1 by 1 rectangle.
Hand In: Tar and email your code to your instructor with a subject of cpsc170 postlab11.