Flood Fill vs Boundary Fill: Key Differences, Use Cases & Performance
Flood Fill colors an entire connected region from a starting pixel until any non-target color is met. Boundary Fill only repaints inside a closed outline, stopping at the border color you specify.
Art students flood-fill to color digital sketches quickly, but when they accidentally erase the outline, the color leaks everywhere—cue confusion with Boundary Fill, which needs that outline to stay intact.
Key Differences
Flood Fill uses a color-replacement test; Boundary Fill tests against a boundary color. Flood Fill risks overflow if edges are imperfect; Boundary Fill is safer but fails if the outline is broken or anti-aliased.
Which One Should You Choose?
Use Flood Fill for quick bucket fills in simple art or maze solving. Pick Boundary Fill for UI rendering, CAD fills, or any case where strict containment matters more than raw speed.
Can Flood Fill work without a boundary?
Yes; it just stops when it meets any color different from the starting one, so accidental gaps cause leaks.
Does Boundary Fill need perfect outlines?
Absolutely. Even a one-pixel break lets the color spill outside, ruining the fill.