How to draw transparency text
JurekGP

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?

Edgar Reynaldo

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

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.

Edgar Reynaldo

You can do the same thing with bitmaps with
al_draw_tinted_bitmap(bmp , al_map_rgba(a,a,a,a) , 0 , 0 , 0);

JurekGP

You're right again, thanks ;)

Thread #615564. Printed from Allegro.cc