Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

color fills

This topic is 5863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

does anyone know of any resources on doing color fills (as in the kind seen in paint programs, usually signified by a bucket).. I am looking for a guide to writing such algorithms but so far no luck.

Share this post


Link to post
Share on other sites
Advertisement
Well, here''s the dumb way to do it... The reason it''s dumb is because it uses recursion. Since the recursion depth can get really high, basically this can only fill a small region or your computer runs out of memory =)

Fill(int x, int y, int color)
{
if pixel at (x,y) isn''t color then
putpixel(x, y, color)
fill(x-1, y, color)
fill(x+1, y, color)
fill(x, y-1, color)
fill(x, y+1, color)
}
This is just some rough pseudocode- you might have to do a little bit of extra error checking...
Anyway, if someone else posts a non-recursive algorithm, use that one instead, hehe =)

Share this post


Link to post
Share on other sites
yeah that was basically what i was using.. i need to find some way to write a flood fill that doesn''t use as much memory

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!