getr(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– getr(3) β€” the Allegro color-peek era πŸ’–

okay bestie, so this is getr(3), one of the Allegro manual pages, and it's literally the ✨ Allegro game programming library ✨ era. buckle up πŸŽ€


✨ NAME ✨

getr, getg, getb, geta β€” pull one single color component out of whatever pixel format you're currently living in πŸ’… and yeah, it's the Allegro game programming library, obviously 🫢


🌸 SYNOPSIS 🌸

#include <allegro.h>

int getr(int c);

int getg(int c);

int getb(int c);

int geta(int c);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: you hand these girls a color, and it's a color in the format that the current video mode is using, and they hand you back exactly one of its components β€” red, green, blue, or alpha 🌈 β€” and that component comes back ranging 0-255.

how do they do it?? no cap, they call the preceding 8, 15, 16, 24, or 32-bit get functions as appropriate πŸ‘‘ like, whichever one matches your current depth. the right girl for the right job, periodt.

🚨 important tea: the alpha part is only meaningful for 32-bit pixels. if you're not on 32-bit, don't come crying to alpha, she's not even really there 😭

and here's the example, look at her go ✨

int r, g, b, color_value;

color_value = getpixel(screen, 100, 100);
r = getr(color_value);
g = getg(color_value);
b = getb(color_value);

main character energy fr fr πŸ’– grab a pixel, then dissect it into its little component babies. obsessed.


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page bestie, no notes πŸŽ€

this one's from the Allegro manual, version 4.4.3, and yeah it's literally tagged getr(3) β€” slay, stay hydrated, go read a pixel πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from