Skip to main content
GameDev.net gamedev.net
🔒 Locked

Fill Algorithm

Started by CuteBug Apr 27, 2003 at 2:02 PM 8 replies 1.2k views
Original Post
CuteBug
CuteBug
Which is the best ad fastest fill algorithm? And how do we implement it? "A byte is a large bit to crunch!"
"There is a Bug in every Code!"
Eelco
Eelco
well when i read your post i thought you meant floodfilling, instead of filling a triangle.
in case you meant the floodfilling: dont use a recursive function! just have some sort of FIFO queue, add pixels/squares/stuff to be expanded (those around the pixel currently handled) to it, and repeat the same for those added to the list, until its empty.
CuteBug
CuteBug
Even the fill algorithm using a list takes too much time to fill. Which algorithm is used by popular softwares like Flash etc to instantly fill a closed region?
Please also provide the implementation...

Thanx a lot.

"A byte is a large bit to crunch!"
"There is a Bug in every Code!"
Eelco
Eelco
so youre talking about filling a region with known borders? that indeed allows for much faster filling, but it can be slightly hard for some shapes. the general way is to just draw horizontal lines fitting the shape, but the way to find the x-coordinates of those lines varys with different shapes. what shape do you want to fill?
RPGeezus
RPGeezus
Flash is filling polygons, if I am not mistaken. There are plenty of articles on polygon filling out there. This is usually pretty fast.

Are you interested in Polygon filling, or flood fliling (like MS Paint?) This tends to be slower.

Cheers,
Will
CuteBug
CuteBug
Well I am certainly interested in Polygon Filling. Plz suggest me from where I can obtain relevant Information about this algorithm.

Thanx a lot.

"A byte is a large bit to crunch!"
"There is a Bug in every Code!"
Ilici
Ilici
divide the poly into triangles. (simple for convex polys_

for a triangle sort the points by the y and fill along scanlines
Eelco
Eelco
you can probably find tons of info on this subject on google, but the above is the general idea.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.