Code archives/Graphics/Text like Blitz3d's :)

This code has been declared by its author to be Public Domain code.

Download source code

Text like Blitz3d's :) by *2011
Draw text like Blitz3d's with centering and everything :)
Function Text( Sentence:String, X:Long, Y:Long, CenterX:Byte = False, CenterY:Byte = False )
	Local XPos:Long = X
	Local YPos:Long = Y
	
	If CenterX=True Then XPos :- ( TextWidth( Sentence ) /2 )
	If CenterY=True Then YPos :- ( TextHeight( Sentence ) /2 )
	
	DrawText Sentence, XPos, YPos
End Function

Comments

sting2011
If CenterX=True Then YPos

Should be


If CenterY=True Then YPos


*2011
oops missed that bit :)


Oddball2011
Hi EdzUp[GD],

If you use SetHandle to do this then the function will also be compatible with scale and rotation.
SuperStrict

Graphics 800,600

Global r:Int

Repeat
	r:+1
	SetRotation r
	SetScale Cos(r)+2,Sin(r)+2
	Cls
	Text 400,300,"Blitz3D-like text",True,True
	Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

Function Text(x#,y#,str$,center_x%=False,center_y%=False)
	Local hx#,hy#,cx#,cy#
	GetHandle hx,hy
	If center_x Then cx=TextWidth(str)*.5
	If center_y Then cy=TextHeight(str)*.5
	SetHandle cx,cy
	
	DrawText str,x,y
	
	SetHandle hx,hy
End Function



Code Archives Forum