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.

DarkBASIC Professional Discussion / Parallelogram - 4 Corner Box FIll Function

Author
Message
Firesea
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 28th Apr 2003 17:18
I'm needing a box fill function that allows you to specify all 4 corners then fills with a color - basically a parallelogram or Trapezoid function fill.

Does anyone have any fast code they would be willing to share?

I would be most grateful.

Firesea
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 28th Apr 2003 20:24
DBPro does this already. Read the help file on the "box" command or see the Tutorial (number 5) on this site. No need to reinvent this wheel.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Apr 2003 20:35
I think that you misunderstood what he wants Rich. He doesn't want just a rectangular shape, he wants a more general 4 sided filled polygon.

I think I'll have a go at it.
Firesea
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 28th Apr 2003 20:44
Rich,

Thank you for the reply - my hope exactly - don't reinvent the wheel but... unles I'm missing something obvious,

I would like specify all four corners of the box for their vertex (x,y)(not color). The vertex(s) do not share the same x or y like the box command assumes.
(it's not a box but really a polyhedron with four sides) . I was hoping even for a fill triangle function using 3 of the four vertexs each time. It is most like the VB function where you can specify all four points of a box then fill it with a color.

Does DBPro have this function?
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 28th Apr 2003 20:47
Ian - I should have read beyond his "I'm needing a box fill function that allows you to specify all 4 corners then fills with a color" part

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Apr 2003 22:50 Edited at: 28th Apr 2003 22:51
Whoo. I got there in the end.

Ok, this is going to need an explanation.

First, a triangle with a flat top or bottom is easy to draw - just take my word for it
Secondly, a triangle without a flat top or bottom can be broken into two triangles, one with a flat top and the other with a flat bottom.
Next, any polygon with three sides or more can be drawn with 1 or more triangles - this is the basis of the 3D we use every day.

If you look through the code, you'll see that everything is arranged as I've detailed above. I've used the box command because it's faster at drawing horizontal lines than the line command.

Firesea
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 28th Apr 2003 23:06
WONDERFUL!! Mine doesn't display but my graphics card is acting screwy today anyway, I'll try it at home.

Thanks a million. I think this function will be useful for alot of the terrains and matrix users. Here you can take any four "height" pts of your matrix, along with the x,y and fill in the area with a color - no texture capture. Or.. as in my case, subdivide the matrix grid into smaller areas with different colors.

I was reading since my original post and it seems the only way is to sort the Y coordinates, locate the Y coordinate for each edge of the triangle or polygon, then draw lines from one edge to the other checking against the edges. Not quite sure I follow your flat triangle example - but let me think a spell on it.

Many thanks Ian!!

Firesea

Login to post a reply

Server time is: 2026-07-10 23:12:49
Your offset time is: 2026-07-10 23:12:49