palette_color(3)

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

πŸ¦‹ palette_color(3) πŸ¦‹

okay bestie, we're in the Allegro manual and this page is all about palette_color(3) β€” the palette index β†’ pixel format translator, no cap. It's part of the Allegro game programming library, and it's lowkey iconic. Let's get into it. πŸ’…


✨ NAME ✨

palette_color β€” maps palette indexes into the current pixel format colors. Allegro game programming library.


🌸 SYNOPSIS 🌸

#include <allegro.h>

extern int palette_color[256];

πŸ’– DESCRIPTION πŸ’–

So palette_color is a table, bestie. It maps palette index colors (0-255) into whatever pixel format is being used by the current display mode. Literally a glow-up from palette index to on-screen pixel value. ✨

In a 256-color mode, it's giving simple: this just maps onto the array index. In truecolor modes, it looks up the specified entry in the current palette, and converts that RGB value into the appropriate packed pixel format. Obsessed. 🫢

Example, because we love a demo:

set_color_depth(32);
...
set_palette(desktop_palette);
/* Put a pixel with the color 2 (green) of the palette */
putpixel(screen, 100, 100, palette_color[2]);

πŸŽ€ SEE ALSO πŸŽ€


mwah πŸ’‹ this page comes from the Allegro manual, version 4.4.3 β€” source/version check, and the footer didn't hand us a date, so that's the whole footer tea. bye bestie 🫢✨

πŸ“¦ where this page comes from