Re: flood fills



        I guess I'm replying this purly
out of interest. I dont know of a function
that does this (but there is probably
a method; once you browse the gimp code
you'll find it somewhere).

        But I did an exersize like that
once for fun. the tough part is that you can
do it really simply and optimized if the shape
is non-concave. otherwise what I came up 
with was something like this:

void func(x, y, color, delimiter) 
{
        draw(x, y, color)

        if ( get_color(x+1,y) != color &&
           ( get_color(x+1,y) != delimiter ) {
                func(x+1, y, color, delimiter);
        }
        /* and repeat the procedure
           for the other 7 surounding 
           points
         */
}

Have fun coding this one!
                -Tristan

Bryan Brown wrote:

I've almost finished the first Linux beta version of my application
(ported from the Amiga), and the final thing I need is a function to flood
fill a demarcated region of somewhat arbitrary shape in a drawing area.

The Amiga has/had a built in function to flood fill a bounded region in a
window with a user-specified color, the input being the RastPort ID and
the screen coordinates of a point within the region.  It worked
wonderfully, even for the most bizarre and convoluted shapes I tried it
on.  Unfortunately I don't have the algorithm it used.

The closest analog I can find in Gtk is to specify a flood fill flag when
drawing a closed figure using a set of points, but nothing about filling
an already-drawn figure.

Is there a Gtk function that I've missed that will do this?

In the absence of such a Gtk function I've written my own rather
unsophisticated function to do it, but it doesn't completely fill regions
of arbitrary shape in one swell foop the way the Amiga did.

Thanks,

Bryan

*---------------------------------------------------------------
* Bryan Brown      <*>              bbrown radix net
* http://www.radix.net/~bbrown
*---------------------------------------------------------------

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]