Scanline Fill
The algorithm can be sped up by filling lines. Instead of pushing each potential future pixel coordinate on the stack, it inspects the neighbour lines (previous and next) to find adjacent segments that may be filled in a future pass; the coordinates (either the start or the end) of the line segment are pushed on the stack. In most cases this scanline algorithm is at least an order of magnitude faster than the per-pixel one.
Efficiency: each pixel is checked once.
Read more about this topic: Flood Fill
Famous quotes containing the word fill:
“I pity the men whose natural pleasures are burthens, and who fly from joy ... as if it was really an evil in itself.... Poor unfortunate creature that he is! as if the causes of anguish in the heart were not enowbut he must fill up the measure, with those of caprice; and not only walk in a vain shadow,but disquiet himself in vain too.”
—Laurence Sterne (17131768)