Flood Fill

by Crazy Star


Posted on March 01, 2007 at 7:04 AM



So I'm making a paint program sort off and searches 64D for a flood fill example and fail to find one. That's a lie actually but it could have been true! What part of it was a lie you probably wonder but I'm not going to tell you =)

Features:
* Flood fill using ds_maps for maximum speed possible. (If you have a faster flood fill example don't hesitate to comment with link to it)
* Draw thick lines scripts.


EDIT
<h4>ESC STOPS THE FLOODFILL</h4>

Added screenshot and a commented version that can be found here:
http://www.dropdeadnow.dk/floodfill2.gmk



headless commented March 01, 2007 at 8:37 AM
very nice
but pretty slow. And for an example you should explain what is happening in the scripts.
7/10
keep it up
areus commented March 01, 2007 at 9:34 AM
Worked fine... Heres the problem. MSPAINT IS THE BEST PAINT PROGRAM EVER!!!! Why try to make anything else...
Polystyrene Man commented March 01, 2007 at 11:22 AM
MSPAINT IS THE BEST PAINT PROGRAM EVER!!!!
Quote
Ha, you're so silly.

It worked fine, but it was ridiculously slow. As in, I dropped down to 5 FPS and had to ctrl+alt+del to get it to stop.
Matsjiht commented March 01, 2007 at 11:36 AM
It does what it's supposed to do, but - like headless said - it's very slow. It worked very nice, and it's an original example, so I'll rate it 8/10
Crazy Star commented March 01, 2007 at 2:51 PM
<small>[defending my example]</small>
It is impossible to make a faster flood fill procedure in GM. Prove me wrong.
Remember that this can be used for other things than paint programs that doesn't require such large areas to fill. An example would be a RTS game where the room is divided up in a grid and you need to figure out if an area is accessible from where you stand. With a large gridsize and a small room that would work pretty well using this example.
Another example is if you have a sprite and you need to convert it to a polygon. For doing that one of the steps could be adding all pixels adjacent to a transparent pixel to a list for all transparent areas on the sprite. That was actually the intended use of this and why it has been made. I'm sure you can think of other uses yourself, as floodfilling is used a lot in programming.
<small>[/defending my example]</small>

<b>Thanks for taking the time to comment.</b>

@ headless
Yeah I'll edit later with some comments... this was designed to be used in a paint program (for very small sprites) so the code might be a little weird placed or whattosay.

@ areus
http://www.humanbalance.net/gale/us/
@ Polystyrene Man
Yeah I should probably put a warning and ensmall the canvas.

@ Matsjiht
Thank you. I hope you find a use for it.
gtvg commented March 01, 2007 at 3:08 PM
Pretty slow, but its the fastest GM floodfill I've seen. Good job!

9/10
Tyranic-Moron commented March 01, 2007 at 6:19 PM
Surprisingly quick, for GM. Nice work.
Crazy Star commented March 01, 2007 at 7:03 PM
@ GTVG
Thanks. It's much appreciated.

@ Tyranic-Moron
Also a big thanks to you.
Obelisk commented March 01, 2007 at 9:17 PM
Good example, but how about a flood that doesn't take 40 days and 40 nights?

8/10
FredFredrickson commented March 02, 2007 at 12:29 AM
The image made me think it said "blood fill" for a second. [:D]
Crane-ium commented March 02, 2007 at 1:28 AM
Actually, I thought that was pretty cool how it filled. Rather distasteful looking bucket you have as a preview though. 8/10 for it.
Meta Chaz commented March 03, 2007 at 10:23 PM
Cool, but a little slow
Tyranic-Moron commented March 06, 2007 at 7:34 AM
I found a faster one... knew I had one somewhere.

http://www.64digits.com/download.php?name=Floodfill_v3.gm6&id=15961
Not by me, 'tis by Sinaz of the GMC. I admit it takes a while to generate the flood-mask, but it is faster after that.
Coffee commented March 07, 2007 at 11:32 PM
Its even faster when you change the room speed to 9999 ;)

^_^

Very nice, maybe I'll remake my paint example with this, and give credit of course.
Crazy Star commented March 13, 2007 at 1:24 PM
I found a faster one
Tyranic-Moron

Awesome, if I ever need to flood fill something that I already knows what looks like I'll use that technique instead. I'm not being sarcastic. I actually wanted to see if a faster method was available, that's why I wrote that it was impossible, heh...


Its even faster when you change the room speed to 9999 ;)
MFTiger

Yeah but the reason I didn't do that is because it would cause a big lag.
Wolfprogramming commented March 20, 2007 at 2:04 PM
10 / 10