Non-fill Draw Shapes

BlitzMax Forums/BlitzMax Beginners Area/Non-fill Draw Shapes

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The easiest way to draw a rectangle outline:
Function DrawOblong( x#, y#, w#, h# )
DrawLine( x , y , x + w , y)
DrawLine( x+w , y , x + w , y+h)
DrawLine( x+w , y+h , x , y+h)
DrawLine( x , y+h , x , y)
End Function

And to create a ellipse outline:
(X and Y are centre of oval, w & h are RADIUS.)
Function drawOvate( x# , y# , w# , h#)
For Local n% = 1 To 360
	Plot( x + w * Cos(n) , y + h * Sin(n) )
Next
End Function

Lastly an ellipse that fits within the specified rectangular area (in the same way that the blitzmax drawoval does)
Function drawEllipse( x# , y# , w# , h#)
Local rh% = h / 2
Local rw% = w/2
For Local n% = 1 To 360
	Plot( rw + x + rw * Cos(n) , rh + y + rh * Sin(n) )
Next
End Function


On a speed note:
It is 5 times quicker to draw a filled rectangle inside another filled rectangle using Blitzmax drawrect() than drawing the four lines to make to edges.

Drawing an oval with either of the latter two functions is about 20 times slower than the Blitzmax drawOval().

Hope this helps.