Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to draw transparency text

This thread is locked; no one can reply to it. rss feed Print
How to draw transparency text
JurekGP
Member #15,891
February 2015

I want to draw my text as an animation from total transparency to normal look text. I tried like that:
al_draw_text(font, al_map_rgba(255, 255, 255, txtTrans), 20, 20, 0, title.c_str());
and I changing txtTrans by some time, but it doesn't work. And I wrote just 0 to make sure.
Someone know how I can get this effect? Maybe through bitmap font? But this way, I think is not optimal, isn't it?

Hi! I'm Pole and my english is not very well. So, please understanding to me. :)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It depends on the blender in use. The default blender is the pre-multiplied alpha blender, which expects pre-multiplied alpha values to be passed to it, for example 100%translucent would be al_map_rgba(0,0,0,0) - because you need to multiply the color values by the alpha values. Ie - al_map_rgba((r*a)/255 , (g*a)/255 , (b*a)/255 , a)

JurekGP
Member #15,891
February 2015

It works, thank you! ;)

By the way I ask for this about bitmap. Does exist any method to draw bitmap like that?
I can tint it, but coloring bitmap is not good idea. This is good way to get a shadow for example, if I tint with color al_map_rgba(0, 0, 0, a). Differently is with strings. They must be tinted.

Hi! I'm Pole and my english is not very well. So, please understanding to me. :)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

JurekGP
Member #15,891
February 2015

You're right again, thanks ;)

Hi! I'm Pole and my english is not very well. So, please understanding to me. :)

Go to: