setting font alignment

BlitzMax Forums/BlitzMax Beginners Area/setting font alignment

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.

heres a function I did. You can draw aligned text with it:
SuperStrict

Rem
	The Draw Al Text Function :: Can be used just like drawtext
EndRem
Function DrawAlText(text$, x#, y#, w# = 0, h# = 0, xAl# = 0, yAl# = 0, xoff# = 0, yoff# = 0)
	
	Local tx#, ty#
	
	Select xAl
		
		Case 0
			tx = x + xoff
				
		Case 1
			tx = (x + (w / 2)) - (TextWidth(text) / 2) + xoff
				
		Case 2
			tx = (w - TextWidth(text)) + xoff
		
	End Select
	
	Select yAl
	
		Case 0
			ty = y + yoff
			
		Case 1
			ty = (y + (h / 2)) - (TextHeight(text) / 2) + yoff
			
		Case 2
			ty = (y + (h - TextHeight(text))) + yoff
			
	End Select
	
	DrawText text, tx, ty
		
End Function

Rem
	===========================================================================
	D	E	M	O
	===========================================================================
EndRem
Graphics 800 , 600

Global curXAl#, curYAl#

While Not KeyDown(KEY_ESCAPE)
	
	Cls
	
	If KeyHit(KEY_RIGHT) Then curXAl:+ 1; If curXAl > 2 Then curXAl = 0
	If KeyHit(KEY_LEFT) Then curXAl:- 1; If curXAl < 0 Then curXAl = 2
	
	If KeyHit(KEY_DOWN) Then curYAl:+ 1; If curYAl > 2 Then curYAl = 0
	If KeyHit(KEY_UP) Then curYAl:- 1; If curYAl < 0 Then curYAl = 2
	
	DrawAlText("Hello" , 0 , 0 , 800 , 600 , curXAl , curYAl , 0) 
	
	Select curXAl
		
		Case 0
			DrawAlText("X :: Left" , 10 , 10) 
			
		Case 1
			DrawAlText("X :: Center" , 10 , 10) 
			
		Case 2
			DrawAlText("X :: Right" , 10 , 10) 
			
	End Select
	
	Select curYAl
		
		Case 0
			DrawAlText("Y :: Top" , 10 , 20) 
			
		Case 1
			DrawAlText("Y :: Center" , 10 , 20) 
			
		Case 2
			DrawAlText("Y :: Bottom" , 10 , 20) 
			
	End Select
	
	Flip
	
Wend