best way for drawing tinted text
William Labbett


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

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

Mark Oates

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

cool. Thanks to you both.

A pleasant suprise.

Thread #606127. Printed from