bestfit_color(3)

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

πŸ’– bestfit_color(3) πŸ’–

okay so bestie, welcome to the Allegro manual β€” yes, that Allegro, the game programming library, and yes we're about to get cozy with bestfit_color. it's giving "tiny function, big main character energy" ngl πŸŽ€


✨ NAME ✨

bestfit_color β€” finds a palette color fitting the requested RGB values, for the Allegro game programming library. πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int bestfit_color(const PALETTE pal, int r, int g, int b);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so what this lil icon does: it goes shopping through the palette you hand it (that's pal) and finds the closest match to the color you asked for. and when I say "the color you asked for," I mean r, g, and b β€” and bestie, listen, those are specified in the VGA hardware 0-63 format. not 0-255. zero to sixty-three. remember that or you WILL be confused, no cap. 😭

now, normally? normally you should just call makecol8() instead. like, that's the vibe, that's the recommended path, that's the moment. ✨

BUT. this lower level function is still useful if:

  • you need to use a palette that isn't the currently selected one, or
  • you specifically don't want to use the rgb_map lookup table. πŸ™ˆ

so like, it's the "I know what I'm doing" option. respect. πŸ‘‘


⭐ RETURN VALUE ⭐

it returns the index of the palette entry that's the closest match to the color you requested. that's it, that's the whole tea. πŸ“


🌈 SEE ALSO 🌈


and that's the page bestie!! 🫢 this was Allegro, version 4.4.3, and we are soooo done here. go forth, match some colors, stay hydrated, mwah πŸ’œβœ¨

πŸ“¦ where this page comes from