CPSC 170 Post Lab 9
Paint Bucket
Due Before Class on Friday, March 19th

sudoku puzzle

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.

Details

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. You can draw a pixel to the image using the setRGB method of the BufferedImage class. Be sure to test your program on small shapes. What happens if you try to fill large shapes?


Submission: Tar and submit your code on the course blackboard site.