1. fast fill routine/fractals

Does anybody have a fast flood fill routine for complex outlines? The
offerings in the archive are quite slow. I want it for a boundary trace
fractal drawing method and at the moment the fill is slower than the trace.

I have no idea how to approach a good routine, but i expect assembly
could be employed. Working on a virtual screen might then be convienient.
Who could take on such an arduous task :?,

new topic     » topic index » view message » categorize

2. Re: fast fill routine/fractals

There's some information on flood-filling (polygon fillers) to be found
in Hornet's code archive (www.hornet.org) and at cubic team's site
(www.cubic.org).
The code examples are mostly in C or C++ but they are portable to
Euphoria (I've done so myself). The only problem with these routines are
that they can't handle complex polygons. They can handle triangles,
pentagons, octagons and so on, but you couldn't make a polygon that
looks for example like a star and fill it with these routines. They also
have some problems with the order in wich the coordinates are given.
These problems can probably be fixed by modifying the routines though...


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: fast fill routine/fractals

Message text written by Nick Metcalfe
>Does anybody have a fast flood fill routine for complex outlines? The
offerings in the archive are quite slow. I want it for a boundary trace
fractal drawing method and at the moment the fill is slower than the trac=
e.
<

Here is a flood-fill routine based one one I used in a sprite editor
program.  There may be faster routines out there (I didn't look).  The
routine works for any complicated outline.  It can easily be modified to
fill with a pattern.  Since the math is simple, it could be coded in
assembler without too much difficulty.  - Colin Taylor

<code>
function fill(sequence bitmap, sequence start_loc, integer new_color)
-- fills contiguous pixels of old_color with new_color
    integer old_color, working
    sequence map
    old_color =3D bitmap[start_loc[2]][start_loc[1]]
    bitmap[start_loc[2]][start_loc[1]] =3D new_color
    map =3D repeat(repeat(0, length(bitmap[1])+2), length(bitmap)+2)
    map[start_loc[2]+1][start_loc[1]+1] =3D 1
    working =3D 1
    while working do
        -- forward pass
        working =3D 0
        for i =3D 1 to length(bitmap) do
            for j =3D 1 to length(bitmap[i]) do
                if bitmap[i][j] =3D old_color then
                    if (map[i][j+1] or map[i+1][j] or
                            map[i+2][j+1] or map[i+1][j+2]) then
                        bitmap[i][j] =3D new_color
                        map[i+1][j+1] =3D 1
                        working =3D 1
                    end if
                end if
            end for
        end for
        -- backward pass
        if working then
            working =3D 0
            for i =3D length(bitmap) to 1 by -1 do
                for j =3D length(bitmap[i]) to 1 by -1 do
                    if bitmap[i][j] =3D old_color then
                        if (map[i][j+1] or map[i+1][j] or
                                map[i+2][j+1] or map[i+1][j+2]) then
                            bitmap[i][j] =3D new_color
                            map[i+1][j+1] =3D 1
                            working =3D 1
                        end if
                    end if
                end for
            end for
        end if
    end while
    return bitmap
end function  -- fill
</code>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu