Drawing a filled 'T' shape using DrawPoly

BlitzMax Forums/BlitzMax Beginners Area/Drawing a filled 'T' shape using DrawPoly

GreenVertical(Posted 2015) [#1]
Hi
I seem to be having problems doing something which should be quite basic. I am just trying to draw a filled 'T' shape using the drawPoly command. However when I draw the coordinates using drawPolyl BlitzMax draws it incorrectly on screen: I don't get a T shape but an asymmetric shape with a diagonal line on the left hand side. As far as I can tell the problem is not with the coordinates I give to drawPoly: When I use the exam same coordinates to draw an outline T (using a series of DrawLine commands) I get the correct shape and no diagonal is present.

I must be doing something wrong with DrawPoly but I have no idea what. Perhaps drawPoly has some a limit on the number of coordinate points you can feed to it (the example 3 point coordinates to draw a filled triangle works fine), or am I misunderstanding something basic about how drawPoly works?

thanks in advance

Here is my code:
Strict
SetGraphicsDriver  GLMax2DDriver()
Graphics 800, 600

Const ShapeSize=400
Const ShapeThickness=100
Global scWIdth, scHeight,scCentrex, scCentrey
scWidth = GraphicsWidth(); scHeight = GraphicsHeight(); scCentrex=scWidth / 2; scCentrey=scHeight / 2

While Not KeyHit(key_escape) '0 is pre trial (i.e. START SCREEN)
	Cls
	DrawTShape(scCentreX,scCentreY,ShapeSize,ShapeThickness)
	Flip 1
Wend 


Function DrawTShape(x:Int,y:Int,S:Int,tk:Int)
	Local pt:Float[8,2] 'pt[i,0]=x coordinate; pt[i,1]= ycoordinate
	Local i:Int
	pt[0,0]=x-s/2; 		pt[0,1]=y-s/2
	pt[1,0]=x+s/2; 		pt[1,1]=pt[0,1]
	pt[2,0]=pt[1,0];		pt[2,1]=pt[0,1]+tk
	pt[3,0]=x+tk/2;		pt[3,1]=pt[2,1]
	pt[4,0]=pt[3,0];		pt[4,1]=y+s/2
	pt[5,0]=x-(tk/2);	pt[5,1]=pt[4,1]
	pt[6,0]=pt[5,0] 		pt[6,1]=pt[3,1]
	pt[7,0]=pt[0,0];		pt[7,1]=pt[3,1]
	
	Local TShp:Float[]=[  pt[0,0],pt[0,1], pt[1,0],pt[1,1], pt[2,0],pt[2,1] , pt[3,0],pt[3,1],  pt[4,0],pt[4,1], pt[5,0],pt[5,1], pt[6,0],pt[6,1], pt[7,0],pt[7,1]  ]
	
	'draw a red filled 'T'
	SetColor(255,0,0)
	DrawPoly TShp
	
	'draw a green outline 'T' at the same location
	SetColor(0,255,0)
	For i=0 To 6
		DrawLine( pt[i,0],pt[i,1],  pt[i+1,0],pt[i+1,1] )
	Next 'i
	DrawLine( pt[7,0],pt[7,1], pt[0,0],pt[0,1] ) 'closes the shape by joining To initial point
EndFunction 'drawTShape



GreenVertical(Posted 2015) [#2]
.


GfK(Posted 2015) [#3]
DrawPoly only works with convex polys. To draw a letter T you're going to need two DrawPoly calls - one for the vertical bit, and another for the bit across the top.


GreenVertical(Posted 2015) [#4]
Many thanks GfK
I wish the Docs were a bit better and explicitly mentioned that limitation of the command..!