al_color_linear(3alleg5)
β¨ al_color_linear β¨
okay bestie, welcome to the Allegro 5 API manual, section 3alleg5 π this one's all about al_color_linear, and ngl it's a lil glow-up for your colors.
πΈ NAME πΈ
al_color_linear β it's giving "make me a color from linear sRGB values" and honestly? slay.
π¦ SYNOPSIS π¦
#include <allegro5/allegro_color.h>
ALLEGRO_COLOR al_color_linear(float r, float g, float b)
like yes, three lil floats going in, one ALLEGRO_COLOR coming out. iconic behavior π
π DESCRIPTION π
so basically, this function returns an ALLEGRO_COLOR(3alleg5) structure built from linear sRGB values. periodt.
here's the tea tho: Allegro RGB values are assumed to be sRGB. and the sRGB standard? it's everywhere, fr fr β all kinds of display devices use it. it accounts for a standard gamma correction that gets applied to RGB colors before they ever hit your screen. π
and what does gamma correction even mean? okay so imagine we have a medium gray color, like al_map_rgb_f(0.5,0.5,0.5). we do NOT want the monitor to set that pixel to exactly half the physical maximum intensity. no no. we want an intensity that appears to be half as bright as the maximum β to the actual human eyeballs looking at it πβ¨ in that case it'd be closer to 21% of maximum intensity rather than to 50% intensity. the math is mathing, trust.
so for some applications it may be useful to specify a color in linear sRGB components β and that's exactly when you'd use this function π«Ά for example:
ALLEGRO_COLOR gray = al_color_linear(0.216, 0.216, 0.216);
char html[8];
al_color_rgb_to_html(gray.r, gray.g, gray.b, html); // "#808080"
the way that produces #808080... obsessed, honestly. ππ
β SINCE β
5.2.8 β she's been here since 5.2.8 and she's been serving ever since π
π₯ SEE ALSO π₯
go read those too bestie, they're the other half of the color pipeline π§π
lowkey a reminder: gamma correction is not a vibe you can just skip. it's baked into how sRGB works, so don't come for it.
and that's the whole page, no cap π this was the Allegro reference manual entry for al_color_linear, section 3alleg5 β tysm for reading, mwah πβ¨
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms