Afterglowscreensavers

Flood Fill Screensaver

The Flood Fill screensaver runs a real live flood-fill algorithm, spreading color outward through a randomly walled grid to fill every reachable cell of a region. It is free, runs in your browser, and ESC exits.

Live preview

Flood Fill / Region Growing screensaver — A real flood-fill algorithm spreading through a random maze.

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Flood Fill / Region Growing screensaver works

The saver generates a real random grid of walls and open cells, then starts a flood fill from a random open seed cell.

Each step, the real algorithm visits every unfilled neighbor of the current filled region and adds it to a growing queue.

The fill spreads outward exactly the way a real paint bucket tool works, stopping cleanly at walls and region boundaries.

Once the whole reachable region is filled, it holds briefly, then a fresh random grid and seed cell begin.

Flood fill: from paint buckets to image analysis

Flood fill, also called seed fill, finds and alters the area connected to a start cell that shares a matching attribute, such as the same colour or being an open path, and stops at boundaries. The paint-bucket tool in raster graphics editors is the best known use, and games such as Go and Minesweeper use it to determine which pieces are cleared.

There are two common implementations. A recursive version calls itself on each neighbour, which is short to write but can overflow the call stack on large regions, so it is impractical where stack space is tightly constrained. Moving the recursion into an explicit stack or queue avoids that, at the cost of more memory, and the choice between them changes the order in which the fill spreads. Either way, each cell is marked once visited so work is never repeated. Span filling, which handles horizontal runs of cells at a time, is a further optimisation.

Another choice is connectivity. Four-way fill spreads only to the north, south, east and west neighbours, so it cannot leak through a diagonal gap between two walls, while eight-way fill also includes the diagonals and can. Many bugs where paint spills out of an outline come from that difference.

A worked example

A narrow one-cell-wide corridor still fills completely, cell by cell, while a wall just one cell over stays untouched — exactly the real reachable-region boundary the algorithm respects.

Settings & tips

Frequently asked questions

Is this the real algorithm behind paint bucket tools?
Yes — a real breadth-first flood-fill implementation, the same core technique used in image-editing fill tools.
Why does it stop where it does?
It only fills cells reachable from the seed without crossing a wall — a real, exact boundary, not a visual approximation.
Is a key needed?
No — it is a pure local computation.
Is it free?
Yes — free, no download, in your browser.
What is the difference between 4-way and 8-way flood fill?
The 4-way kind moves only up, down, left and right, while the 8-way kind also moves diagonally. The 8-way version can slip through corner-to-corner gaps that the 4-way version treats as walls.
Why can recursive flood fill crash?
Each recursive call uses stack memory, and a large region can nest deeply enough to overflow it. An explicit queue or stack avoids the limit.
Where else is flood fill used?
Beyond paint-bucket tools, games such as Go and Minesweeper use it to decide which pieces or squares are cleared.

← All Science & Research screensavers