- Online Community Forums » Programming Questions » best way for drawing tinted text

This thread is locked; no one can reply to it. rss feed Print
best way for drawing tinted text
William Labbett
Member #4,486
March 2004


needing to draw some text transparently I'm wondering whether I should draw it to a temporary bitmap first then set the blender and use al_draw_tinted_bitmap or if there's another better way.

please advise... :-/

Thomas Fjellstrom
Member #476
June 2000

Make sure you use the alpha component of the color you give al_draw_text?

Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" --

Mark Oates
Member #1,146
March 2001

Yes, al_draw_text(); contains a color parameter, so just pass a color with alpha.


As of the newest versions of A5 (since 5.0.0 RC3), you'll need to also multiply the color components of your tint by the alpha to get correct results.

ALLEGRO_FONT *font = get_font("UnionBold.ttf", -30);
float alpha = 0.5f;
ALLEGRO_COLOR color = al_map_rgba_f(1.0*alpha, 0.4*alpha, 0.6*alpha, alpha); // <-- correct
//ALLEGRO_COLOR color = al_map_rgba_f(1.0, 0.4, 0.6, alpha); // <--no longer correct

al_draw_text(font, color, 10, 10, NULL, "This is transparent text.");

This is new.

William Labbett
Member #4,486
March 2004

cool. Thanks to you both.

A pleasant suprise.

Go to: