## complex fill

### complex fill

I am writing a mouse-paint program for the IBM-PC.

I am looking for an algrorithm to fill complex areas.  It must fill the area
knowing only one point in the area and by detecting the border by a change of
color.  It would be nice if it took into account the edge of the screen.

Pascal would be preferred, but anything would be appreciated.

Thanks,
Douglas Rand            ihnp4!umn-cs!ndsuvax!ucrand

The problem with many floodfill algorithms is that as the complexity
of the object increases, so does the storage required to handle
decision points. Thus if you have a limited amount of storage, you
cannot guarantee that ANY object can be filled.

I have a complex fill algorithm whose space requirements are static
(i.e. they do not change with the complexity of the object) and works
on ANY complex object. The border is assumed to be 8-connected and the
area to be filled is 4-connected. 8-connected means that a center pixel
is connected to all of the 8 neighbor pixels while 4-connected means that
the center pixel is only connected to the north, south, east and west
pixels. None of the diagonal pixels are connected to a 4-connected pixel.
When filling, you cannot cross the border.

Floodfill algorithms are pretty fast but have a space limitation problem.
My algorithm is fairly fast but slows down a bit as the complexity of the
object increases. Thus the tradeoff is space vs. time although my algorithm
works on any object.