FloodFill on OSX

FloodFill is always an extremely expensive operation. It should only be used as a last resort.

In order to implement a FloodFill, the driver has to read every pixel in the flooding area. There is no shortcut here. It has to start at the coordinate you give, then start reading pixels to the left and right until it finds a different color. Then it has to move up to the previous scanline, and search it for any areas that are the same color, and so on up and down until it hits THOSE borders. It is PAINFULLY slow.

It is always better to compute the actual drawing region yourself and do a straight paint.

ยทยทยท

On Wed, Apr 2, 2008 at 2:57 AM, Timothy Grant <timothy.grant@gmail.com> wrote:

  

> I'm just mucking about with some wxPython code and am a bit flummoxed by
> this behavior..
>
> I have a window with a 'DARKGREY' grid painted on it. I simply want to
> colour the square on the grid I click in a different colour.
>
> dc =3D wx.PaintDC(self)
> dc.SetBrush(wx.Brush('BLUE'))
>
> print dc.Brush.GetColour()
> dc.BeginDrawing()
> if dc.FloodFill((w * GRIDSIZE) + 1, (h * GRIDSIZE) + 1,
> 'DARKGREY', wx.FLOOD_SURFACE):
> print "flood successful"
> else:
> print "flood not successful"
> dc.EndDrawing()
>
> The FloodFIll always prints "flood not successful" and I'm not sure what
> I'm doing wrong.

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.