Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / hot fo fill an irregular n-gon

Author
Message
Ermes
19
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 8th Apr 2011 12:00
qbasic has it, old amos has it, even simon basic for c64 has it.....

but no, db doesn't like to fill anything. i understand the trend is 3d and sprites, but with 2d you can be very stylish, and save memory and disk space.

there is a way to fill irregular n-gons???????

D3D plugin doesn't have it. IanM tell me is working on this, but i think he has more important thing to do.


Ciao facce da sedere!
Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Apr 2011 13:37
You could do your own.

For example, if you had any shape, and a start pixel, you set your start pixel to the fill colour, then continually scan the image, spreading that pixel out until it fill the shape. Then it's a matter of finding a quick technique to fill the area.

I think that the last time I did this, I changed directions after each pass, like pass 1 would spread the fill colour up in a single line until it hits the edge of the shape. Then pass 2 would spread it down, so you have a line across the inside of the shape. Then spread left, then right. Do that repeatedly until all 4 passes finish without adding a single pixel, then you know you are done. By changing the direction of each pass, you can quickly fill in the irregular shapes.

I would suggest doing it with memblocks, as that would be pretty fast I think. But if your totally stuck, I'm sure I could make you a snippet.

Health, Ammo, and bacon and eggs!
Ermes
19
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 8th Apr 2011 14:43
one of the problem is the n-gon is placed above other n-gons.

IanM has a filling command with a border colour options, but it isn't working good.


Ciao facce da sedere!
Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Apr 2011 16:52
So you would want to specify a border colour, then fill in the shape so that everything inside that border colour is filled?

How would you want to specify the border colour? - I mean, I could write a function to do this, you'd pass the border colour in the function, then inside the function it would work out the flood fill, but in a temporary array. The temporary array would let the system do a reverse fill. A reverse fill is like filling the outside of the border, maybe starting at 0,0 - then whatever is left unfilled is replaced by the border colour. That would probably be faster than a traditional flood fill too, because the whole screen could get a border before being scanned - so it might only need 1 or 2 passes, whereas an internal fill might need much more. The speed would depend on how many nooks and crannies you have. I guess it would work a bit like silk screen printing a t-shirt.

I really don't mind looking at stuff like that, should I go ahead and write a function?

Health, Ammo, and bacon and eggs!
Ermes
19
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 8th Apr 2011 17:38
Quote: "So you would want to specify a border colour, then fill in the shape so that everything inside that border colour is filled?
"


you'll be welcome! do you really think you can write this function for me/the comunity???


Ciao facce da sedere!
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Apr 2011 01:12
You can look through these entries from the paint program challenge we had years ago. A few of us made fill algorithms.

http://dbcodecorner.com/index.php?page=view&challenge=Paint%20Program

The Internet: Where men are men, women are men, and children are federal agents
Ermes
19
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 23rd Apr 2011 23:14
Outstanding.

thanks!

SYS 64738

Login to post a reply

Server time is: 2022-12-05 04:13:32
Your offset time is: 2022-12-05 04:13:32