al_color_html_to_rgb(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_color_html_to_rgb β€” Allegro 5 API πŸ’–

okay bestie, gather round, because this one is so handy and also so small. it's an Allegro 5 API function, and it does exactly one (1) job: it takes a hex color string like you'd see in CSS and turns it into actual floating point RGB values. slay.


✨ SYNOPSIS ✨

#include <allegro5/allegro_color.h>

bool al_color_html_to_rgb(char const *string,
   float *red, float *green, float *blue)

🌈 DESCRIPTION 🌈

so basically, this function reads an HTML-style hex number β€” think #00faff β€” and interprets it as a color. that's the whole vibe. πŸ’…

and the only formats it accepts are these two, no substitutions, no exceptions:

  • #RRGGBB
  • RRGGBB

where R, G, and B are hexadecimal digits from the set [0-9A-Fa-f]. that's it. that's the list. don't come at it with your three-digit shorthand, it will simply not eat that. πŸ™ˆ

it returns true on success and false on failure. and on failure β€” listen carefully bestie β€” all components are set to zero. all of them. zeroed out. so if you ignore the return value you're gonna be sitting there wondering why your color is black, and the answer is that you fumbled. 😭

⚠️ Note: the behaviour on invalid strings is different from Allegro 5.0.x. so if you're porting old code and the vibes feel off, that's why. not you, it's the version. 🫢

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, no notes. πŸ’– this was brought to you by the Allegro reference manual, starring al_color_html_to_rgb(3alleg5) in the title role. go forth and convert your hexes, bestie, you've got this. β­πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from