Flood fill is a surprisingly complicated operation. You basically
have to implement it recursively, pixel by pixel. You scan left and
right, up and down, until you find an edge that doesn’t match your
starting color.
Fortunately, wx.DC includes a FloodFill function that can do this
for you.
Erasing is exactly like painting with a brush or pen, except that
you use the background color instead of the foreground color.
You need to have your own list of the objects that includes their
size, color, and position. To move one of them, you change the
position in your list and redraw the scene from scratch.
···
Navaneeth Suresh wrote:
Dear group members,
I am in a work of a graphics software using canvas with
wx.ClientDC, wx.BufferedDC, wx.GCDC and wx.GraphicsContext. But I
am facing some problems as follows:
- I don’t know the program of Bucket Fill tool.
- I don’t know the program of an Eraser tool.
-- Tim Roberts, Providenza & Boekelheide, Inc.
timr@probo.com
Would you please show bucket fill tool with an example ?
Navaneeth,
All you need to do is:
a) Detect where the mouse click took place within your image,
b) get to colour at that point,
c) work outwards from that point replacing any pixels that are the
same colour (within some possibly controllable tolerance)
d) when you get to a point that is a different colour you either
stop spreading in that direction or check for other in tolerance
points within some, possibly controllable, fuzz factor.
For an example download just about any open source paint program and
implement it yourself.
···
On 12/02/13 04:30, Navaneeth Suresh
wrote:
Would you please show bucket fill tool with an example
?
--
You received this message because you are subscribed to the Google
Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it,
send an email to .
For more options, visit .
–
Steve Gadget Barnes
wxpython-users+unsubscribe@googlegroups.com
https://groups.google.com/groups/opt_out
Navaneeth Suresh wrote:
Would you please show bucket fill tool with an example ?
Well, what do you already have? There is documentation for the
FloodFill function that describes how to use it. You tell it where to
start, and you tell it how to stop. You can either give it a color and
say "only fill areas that match this color", or you can give it a border
color and say "fill until you reach a border of this color". It always
fills with the current brush.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Thankyou all for your replies. I am glad to see it. See the screenshot my software [attached image]. Send your valuable suggestions to me. After completing my work, I will send you the whole project.

Navaneeth Suresh wrote:
Thankyou all for your replies. I am glad to see it. See the screenshot
my software [attached image]. Send your valuable suggestions to me.
After completing my work, I will send you the whole project.
Did you see the previous suggestions? When you click your "bucket fill"
tool in the image, you will want to use "GetPixel" to fetch the color of
the pixel under the tool, then call FloodFill to have it replace that
color with whatever your current background color is. It's not really
all that difficult.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Yes sir. It works. When the tool is enabled it starts working. When we click a place on canvas the tool will replace that colour to the current fill colour.
See the source code :
dc.FloodFill(event.GetX(), event.GetY(), dc.GetPixel(event.GetX(), event.GetY()))
What are the other possibilities and other tools which I can include in my application ?
Navaneeth Suresh wrote:
Yes sir. It works. When the tool is enabled it starts working. When we
click a place on canvas the tool will replace that colour to the
current fill colour.
See the source code :
dc.FloodFill(event.GetX(), event.GetY(), dc.GetPixel(event.GetX(),
event.GetY()))
What are the other possibilities and other tools which I can include
in my application ?
That's up to you, of course. What do you want it to do? Tools like
Photoshop and gimp have a virtually unlimited number of drawing tools.
Bezier curves would be an interesting option, although there is math
involved there.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.