Can people comment on these functions collated from various threads and codearchives? I realise there are other ways of doing this but they all use native Bmax commands which is why I selected them over other methods. If you have reasons why another method should be used then please give reasons
Cheekily called them 'ce_' for Community Edition so hope people don't mind.
.
p.s. This post is in relation to :
BlitzMaxier 2D? thread.
<edit> I think I posted the wrong one so updated.
Cheekily called them 'ce_' for Community Edition so hope people don't mind.
.
SuperStrict Graphics 800,600 SetColor 255,0,0 ce_drawrect(0 , 0 , 100 , 100) ce_drawrect(100,0,100,100,False) SetColor 0,255,0 Local xy:Float[]=[0.0,200.0,100.0,200.0,50.0,300.0] Local xy1:Float[]=[100.0,200.0,200.0,200.0,150.0,300.0] ce_drawpoly(xy,1) ce_DrawPoly(xy1,0) SetColor 0,0,255 ce_drawoval(0,100,100,100,1) ce_drawoval(100,100,100,100,0) Flip WaitKey() Function ce_DrawPoly( xy:Float[], fill:Int=True, x:Float=0, y:Float=0 ) Local origin_x:Float Local origin_y:Float GetOrigin origin_x,origin_y Local handle_x:Float Local handle_y:Float GetHandle handle_x,handle_y If fill _max2dDriver.DrawPoly xy,.. handle_x,handle_y,.. x+origin_x,y+origin_y Else Local x1:Float=xy[xy.Length-2] Local y1:Float=xy[xy.Length-1] For Local i:Int=0 Until Len xy Step 2 Local x2:Float=xy[i] Local y2:Float=xy[i+1] _max2dDriver.DrawLine.. handle_x+x1,handle_y+y1,.. handle_x+x2,handle_y+y2,.. x+origin_x-0.5,y+origin_y-0.5 x1=x2 y1=y2 Next EndIf End Function Function ce_Drawrect( x:Float, y:Float, w:Float,h:Float, fill:Int=True) If fill DrawRect x,y,w,h Else Local origin_x:Float Local origin_y:Float GetOrigin origin_x,origin_y Local handle_x:Float Local handle_y:Float GetHandle handle_x,handle_y Local xy:Float[]=[x,y,x+w,y,x+w,y+h,x,y+h] Local x1:Float=xy[xy.Length-2] Local y1:Float=xy[xy.Length-1] For Local i:Int=0 Until Len xy Step 2 Local x2:Float=xy[i] Local y2:Float=xy[i+1] DrawLine (handle_x + x1 , handle_y + y1 , handle_x + x2 , handle_y + y2) x1=x2 y1=y2 Next EndIf End Function Function ce_DrawOval( x:Float, y:Float, w:Float,h:Float, fill:Int=True) If fill DrawOval(x,y,w,h) Else Local xr#=(w)*.5 Local yr#=(h)*.5 Local segs:Int=Abs(xr)+Abs(yr) segs=Max(segs,12)&~3 x:+xr y:+yr Local px# = x + xr Local py# = y For Local i:Int=1 To segs Local th#=i*360#/segs Local x#=x+Cos(th)*xr Local y#=y-Sin(th)*yr DrawLine px,py, x, y px# = x py# = y Next EndIf End Function
p.s. This post is in relation to :
BlitzMaxier 2D? thread.
<edit> I think I posted the wrong one so updated.