DrawText Background

BlitzMax Forums/BlitzMax Beginners Area/DrawText Background

pistacchio(Posted 2009) [#1]
Hi,
with SetColor i can set the *foreground* color of a text i draw with DrawText. How to test its *background* color? Thanks


ImaginaryHuman(Posted 2009) [#2]
DrawRect before drawing the text. Text is drawn with alphablending so it can't have both a background and a foreground.


xlsior(Posted 2009) [#3]
Like ImaginaryHuman said, there is no background color, so you'll need to manually blot it out with a drawrect or similar.

You can use the TextWidth and TextHeight commands to find out the dimensions of the text in pixels, so you can figure out where to draw the background rectangle.


Brucey(Posted 2009) [#4]
But also note that TextWidth/Height functions are quite expensive.
You may want to cache the results, if you can.


xlsior(Posted 2009) [#5]
Oh, one more thing: TextHeight and TextWidth do NOT pay attention to any alternate scales that may be defined with SetScale, so if you do draw your images at a different scale, make sure to multiply the results by the same scale to get the accurate size at it would appear on the screen.