[wxpython-users] FloodFill on OSX
Timothy Grant
timothy.grant at gmail.com
Wed Apr 2 09:55:40 PDT 2008
Thanks Tim,
I reworking the code to do what you suggested.
I'd still like to know why what I wrote doesn't work, but I'm not going to
sweat it.
-- =
Stand Fast,
tjg.
On Wed, Apr 2, 2008 at 9:46 AM, Tim Roberts <timr at probo.com> wrote:
> On Wed, Apr 2, 2008 at 2:57 AM, Timothy Grant <timothy.grant at 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 =3D3D 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.
> > >
> >
> 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.
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200804=
02/5e2a1639/attachment.htm
More information about the wxpython-users
mailing list