Flood fill is an algorithm that determines connected regions in an array. It's used in the fill tool of paint programs, in Tetris implementations for determing what falls and what doesn't, and in Puyo Puyo implementations for determining what pieces are cleared.

Flood fill takes four parameters: seed x, seed y, source color, and destination color.

  1. Look to the left of the current element for more elements that match the source color.
  2. Look to the right of the current element for more elements that match the source color.
  3. Fill this horizontal line with the destination color.
  4. For each element above or below (or in 3D, in front of or behind) an element in the horizontal line that matches the source color, run flood fill on that element.
See this algorithm implemented in C with GDK.

Log in or registerto write something here or to contact authors.