Bluffton University > Mathematics > Darryl Nester > Java[Script]: Painting Demonstration


                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
Speed:
  • Hold down the SHIFT key and move across the squares to make them black.
  • Click on a square to reverse its color.
  • Click while holding SHIFT to paint (fill in) the figure.

The painting algorithm works like this: To "paint" starting at row R, column C,

  1. If that point is already black, quit.
  2. Move LEFT until hitting a wall or boundary.
  3. Paint(R-1, C) — the point above.
  4. Paint(R, C+1) — the point to the right.
  5. Paint(R+1, C) — the point below.