March 06, 2021, 05:17:15 AM

Author Topic: [bmx] Draw Shadowed Text by Baystep Productions [ 1+ years ago ]  (Read 651 times)

Offline 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
  1. Function DrawShadowText(text$,x#,y#,depth%=1,opacity#=0.5)
  2.         Local _r%,_g%,_b%,_a%
  3.         GetColor(_r%,_g%,_b%)   'Get current drawing color and save it.
  4.         _a% = GetAlpha()
  5.         SetColor 0,0,0
  6.         SetAlpha _a%-opacity#           'Requires ALPHABLEND
  7.         DrawText(text$,x#+depth%,y#+depth%)
  8.         SetColor _r%,_g%,_b%
  9.         SetAlpha _a%
  10.         DrawText(text$,x#,y#)
  11. 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?


SimplePortal 2.3.6 © 2008-2014, SimplePortal