drawploy : how does it work ?
BlitzMax Forums/BlitzMax Programming/drawploy : how does it work ?
| ||
I'm trying to create a polygon but I dont see what Im doing wrong. To following code I thought would create a polygon shaped like a number 1. something like this : _* _* _* _* *** but when i run it it looks nothing like that. So my question is can I create a polygon like that shape using drawploy or do I have to draw two 4 sided polys ? |
| ||
drawpoly doesn't do concave angles, which is what the top of your "1" is. You need to break the "1" down into two separate polygons. |
| ||
OK.. thats cool.. I can work with that.. I just wasnt sure I was using it correctly. Thanx |
| ||
I don't know if it's mentioned anywhere, but algorithms like drawpoly usually assume the points are in a particular order. The polygon must be traversed counterclockwise.Graphics 640,480 Local angle:Int Local p:Float[8*2] p[0] = -5 p[1] = -25 p[2] = 5 p[3] = -25 p[4] = 5 p[5] = 20 p[6] = 10 p[7] = 20 p[8] = 10 p[9] = 25 p[10] = -10 p[11] = 25 p[12] = -10 p[13] = 20 p[14] = -5 p[15] = 20 ' Quick fix, reverse order of vertices. For n = 0 To 6 Step 2 m = n temp = p[m] ; p[m] = p[14-m] ; p[14-m]=temp m = n + 1 temp = p[m] ; p[m] = p[16-m] ; p[16-m]=temp Next While Not KeyHit(key_space) Cls angle :+ 1 If angle > 360 Then angle :- 360 End If SetOrigin 50,50 SetRotation angle DrawPoly(p) Flip Wend |
| ||
thanx floyd I have already fixed my problem by drawing a collection of rectangles and it will be a bit of a rewrite to do it properly now but I will certainly remember it for next time. If only I'd desgned the poly in reverse order I would never have hit this problem in the first place. :) |