CSC 240: Computer Graphics

Lab 1: Flood Fill

Download lab3.py. In the terminal, run:
python lab3.py 
You should see a white background with the outline of a square.

  1. In the next steps, implement the flood fill algorithm, which will color in the inside of the square "new_color", starting from the pixel at (x,y):
     def flood_fill(img, x, y, old_color, new_color): 
    First, what is the current color at pixel (x,y)?
  2. What should happen if the current color is already the new color?
  3. What should happen if the current color is an edge color?
  4. What should happen if the current color is the old color?
  5. Use recursive calls to fill the rest of the square!
BONUS: Can you make a bigger square (change the half_side variable)? What happens if you try to fill too much area?