Page 1 of 1

How do I fill a freeform object with a color

PostPosted: Tue Aug 16, 2005 2:10 am
by Just4Fun
Could someone point me in the right direction regarding the following problem?

Let's say I have an outline of a map of South America.

When a user clicks on , hmm, let' say, Brazil, I would like this country to be filled with a solid color. The problem is, the map area isn't a nice square. Is it possible to fill shaped areas in Game Editor without using animations? TIA :?:

PostPosted: Tue Aug 16, 2005 3:45 am
by Fuzzy
Maybe make three layers of the country and make each one Red Green, and Blue? Then mess with the transparencies.

PostPosted: Thu Aug 18, 2005 2:53 am
by Just4Fun
Maybe make three layers of the country and make each one Red Green, and Blue? Then mess with the transparencies.


Thanks ThreeFingersPete but...
I would like to do these fills using script. I think it would use the setpixel() function along with x,y, but I'm not sure how to approach it. Any ideas?

PostPosted: Fri Aug 19, 2005 4:07 am
by Fuzzy
so you are doing some sort of risk type game? each country needs a color corrosponding to a certain player/AI?

PostPosted: Fri Aug 19, 2005 5:19 am
by Just4Fun
Hi ThreeFingersPete:

are doing some sort of risk type game?


No, I am just curious regarding how to do a non rectangular fill using script... Setting pixel fills can get pretty complicated(at least for my overtaxed brain).

I'd like to figure out the algorithm that would do the job. That way, maybe I could apply it to whatever problem I encountered. When you look at maps, most areas are not rectangular so I thought that using pixels to set the country's color would be a good challenge.

I know it would be a lot easier for me to create animations, but that might slow things down and cause program bloat. I am not a very good programmer, but I really enjoy looking a how to do things and trying to understand...

Thank you for your interest and trying to help... :D

PostPosted: Fri Aug 19, 2005 11:10 am
by jazz_e_bob
It may be VERY complex.

An interesting challenge.

I can't even think where to begin!

http://www.codeproject.com/gdi/QuickFill.asp

What you want is a "flood fill" algorithm.

There seems to be a few around.

PostPosted: Sat Aug 20, 2005 6:23 am
by Just4Fun
Thank you Jazz,

That is exactly what I was looking for. You are amazing! :shock:

PostPosted: Fri Aug 26, 2005 7:15 pm
by Crusader
ThreeFingerPete wrote:Maybe make three layers of the country and make each one Red Green, and Blue? Then mess with the transparencies.