Filling a polygon. SOLVED.

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
SunShine
Posts: 31
Joined: February 16th, 2013, 2:44 pm

Filling a polygon. SOLVED.

Post by SunShine » February 16th, 2013, 2:59 pm

Hello everyone!

So i saw this post and decided to take the chalange and replicate Luxs polygon drawing function.
http://www.planetchili.net/forum/viewto ... =triangles

It wasn't hard to draw the polygon it self, but the filling part was just imposible for me :(
I tried looking it up on the net, but I couldn't find much help...

Tips or any help on how to fill polygons would be nice :D
Thank you!
Last edited by SunShine on February 23rd, 2013, 11:47 am, edited 1 time in total.

User avatar
GreatJake
Posts: 169
Joined: January 6th, 2013, 5:13 pm
Location: USA

Re: Filling a polygon. HELP!

Post by GreatJake » February 16th, 2013, 5:18 pm

Would you have to do something like shading the inequality? It sounds like you could somehow apply that here.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Filling a polygon. HELP!

Post by LuX » February 18th, 2013, 3:00 pm

Hmm... I wonder how I did it...
ʕ •ᴥ•ʔ

User avatar
SunShine
Posts: 31
Joined: February 16th, 2013, 2:44 pm

Re: Filling a polygon. HELP!

Post by SunShine » February 18th, 2013, 4:04 pm

Hi Lux.

In the other topic you said that you were running through a plane of pixels and checking if the pixel is on the right side of every line. But how can you do that when you only have the corner coordinates :?:

Come on Lux remember the magic, that polygon is asking to be filled :D

Musi
Posts: 106
Joined: November 25th, 2012, 1:06 am

Re: Filling a polygon. HELP!

Post by Musi » February 19th, 2013, 7:42 pm

hmm... maybe testing to see if the angle from vertex to pixel is greater than the angle from vertex to vertex? Just a guess, probably not.
Musi

There are 10 types of people that understand binary.
Those that do, and those that don't.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Filling a polygon. HELP!

Post by LuX » February 20th, 2013, 2:03 pm

The way I did it is check if the pixel is on the right side of all lines, like I explained, I think, in the other topic. If you read it you will also see chili mentioning scan line which would make it a lot faster, but it might be a bit hard for now.
ʕ •ᴥ•ʔ

User avatar
SunShine
Posts: 31
Joined: February 16th, 2013, 2:44 pm

Re: Filling a polygon. HELP!

Post by SunShine » February 20th, 2013, 4:04 pm

Damn! I can't fill it...
I tried what Musi suggested and tried to calculate stuff like Lux said, but I couldnt fill the poly entirely. Most of the time I end up with some strange things on the screen :D
I have seen and read a bit about the scan-line algorithm, but I kinda don't want to go that way. ( it looks complicated on the first look )

To Lux:
Please tell me more how you calcute the lines / vectors.
( what kind of method/algorithm you use )

Thanks!

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Filling a polygon. HELP!

Post by LuX » February 22nd, 2013, 2:03 pm

Google "Determine which side of a line a point is"
ʕ •ᴥ•ʔ

User avatar
SunShine
Posts: 31
Joined: February 16th, 2013, 2:44 pm

Re: Filling a polygon. HELP!

Post by SunShine » February 22nd, 2013, 4:16 pm

Thanks Lux!
I have done it 8-)

Post Reply