User Tools

Site Tools

This is an old revision of the document!


Flood-fill is an algorithm which fills in a contiguous area. The basic algorithm maintains a stack of pixels to check, and for each pixel tested it pushes the neighbours onto the stack.

For this implementation in Javascript it doesn't make any difference, but for an optimised native flood-fill it would be important to test horizontal pixels first (push them onto the stack last). This is important for optimal memory access.

λ flood-fill

An optimised version of this algorithm maintains a stack of scanlines rather than pixels to test. This saves a lot of pixel tests over the basic algorithm.

λ flood-fill_scanline

flood-fill.1352182996.txt.gz · Last modified: 2015/02/02 08:24 (external edit)