al_premul_rgba_f(3)
β¨ 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