views:

221

answers:

2

I'm playing around and try to make a Coloring book for my children and I have a lots of black and white line drawings that I use as backgrounds so they they can paint on them.

Now, I want to add a FILL-function so they can point and click somewhere where its white in the drawing and then let the function fill the whole region within its bounds with a color.

It would be nice to have a function that by sending in X, Y and a color defined for the boundary and get a region out of it. Then its just about to do e.Graphics.FillRegion (brush,region) to fill it with the color.

But I can't find any function that allowes me doing that, and I think its too much job to trace the boundarys myself.

Have I missed some function in the system.drawing class that does this or do you have any other ideas?

Any other ideas for the coloring book-program are also interesting. (Im making the program safe so you can leave the kid in front of the computer without being afraid of the kid accessing any other things on the computer and have different funny sounds when selecting colors and so on)

+1  A: 

Look into flood fill methods. Wikipedia has plenty of information on the subject here.

Cody Brocious
+1  A: 

If the "boundary" is defined by differently-colored pixels and not a mathematical formula or a Path data structure, you will have to test and fill individual pixels. There is an article on how to flood fill in .Net at Code Project.

Dour High Arch