[bmx] Draw Shadowed Text by Baystep Productions [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:43

Previous topic - Next topic

BlitzBot

Title : Draw Shadowed Text
Author : Baystep Productions
Posted : 1+ years ago

Description : 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.


Code :
Code (blitzmax) Select
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 Studios(Posted 1+ years ago)

 *Dumb statement here*


Ked(Posted 1+ years ago)

 <div class="quote"> You might want to add that this requires Fast Image. </div>But, it's BlitzMax code...


Oiduts Studios(Posted 1+ years ago)

 O_O fail...


Pengwin(Posted 1+ years ago)

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