al_premul_rgba_f(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

✨ NAME ✨

okay so bestie, this is al_premul_rgba_f - Allegro 5 API, from the Library Functions Manual πŸ«ΆπŸ’…. It’s the shortcut version of making an ALLEGRO_COLOR where the RGB already got multiplied by alpha, so transparent tinting behaves right 😭✨.

🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

ALLEGRO_COLOR al_premul_rgba_f(float r, float g, float b, float a)

πŸ’– DESCRIPTION πŸ’–

This is literally a shortcut for:

al_map_rgba_f(3)(r * a, g * a, b * a, a)

By default, Allegro uses pre-multiplied alpha for transparent blending of bitmaps and primitives β€” see al_load_bitmap_flags(3) for a discussion of that feature πŸ‘€βœ¨. That means if you want to tint a bitmap or primitive to be transparent, you need to multiply the color components by the alpha components when you pass them to this function. No cap, that’s just how it works πŸ’….

bestie, this is the part where you don’t skip the multiply step β€” pre-multiplied alpha is the default Allegro vibe here 🫢

For example:

float r = 1;
float g = 0;
float b = 0;
float a = 0.5;
ALLEGRO_COLOR c = al_premul_rgba_f(r, g, b, a);
/* Draw the bitmap tinted red and half-transparent. */
al_draw_tinted_bitmap(bmp, c, 0, 0, 0);

This function can be called before Allegro is initialized. πŸ¦‹βœ¨

πŸŽ€ SINCE πŸŽ€

5.1.12 β€” iconic, periodt πŸ’–.

🌈 SEE ALSO 🌈


xoxo, source = Allegro reference manual, page = al_premul_rgba_f(3), date = not listed in the footer πŸ«ΆπŸ’–

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms