Code archives/Graphics/Draw Shadowed Text

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

Download source code

Draw Shadowed Text by Baystep Productions2011
Draws the text of choice at x and y with a shadow underneath it. Saves the current drawing color and alpha before drawing shadows. Shadow depth can be set but its added to x and y equally. Opacity sets the transparency of the shadow combined with the current drawing alpha.

Oh and set your blend modes to use ALPHA if haven't all ready.
Function DrawShadowText(text$,x#,y#,depth%=1,opacity#=0.5)
	Local _r%,_g%,_b%,_a%
	GetColor(_r%,_g%,_b%)	'Get current drawing color and save it.
	_a% = GetAlpha()
	SetColor 0,0,0
	SetAlpha _a%-opacity#		'Requires ALPHABLEND
	DrawText(text$,x#+depth%,y#+depth%)
	SetColor _r%,_g%,_b%
	SetAlpha _a%
	DrawText(text$,x#,y#)
EndFunction

Comments

Oiduts Studios2011
*Dumb statement here*


Ked2011
You might want to add that this requires Fast Image.

But, it's BlitzMax code...


Oiduts Studios2011
O_O fail...


Pengwin2011
Nice routine, just one thing I noted, shouldn't the alpha variable (a%) be a float rather than an integer?


Code Archives Forum