hsv_to_rgb(3)
β¨ hsv_to_rgb(3) β¨
okay bestie, so this one lives in the Allegro manual β the Allegro game programming library β and it's literally just two lil functions that translate colors back and forth between two whole color languages. π
π NAME π
hsv_to_rgb, rgb_to_hsv β converts color values between the HSV and RGB color spaces. it's giving Allegro game programming library. π¦
π SYNOPSIS π
#include <allegro.h>
void hsv_to_rgb(float h, float s, float v, int *r, int *g, int *b);
void rgb_to_hsv(int r, int g, int b, float *h, float *s, float *v);
πΈ DESCRIPTION πΈ
so basically these two convert color values between the HSV and RGB color spaces, no cap. π₯
here's the vibe check on the ranges, and you literally cannot forget these:
- RGB values go from
0to255 - hue goes from
0to360 - saturation and value go from
0to1
and here's the example, i'm not editing a single character of it, periodt:
int r, g, b;
float hue, saturation, value;
...
/* Convert a reddish color to HSV format. */
rgb_to_hsv(255, 0, 128, &hue, &saturation, &value);
/* Now put our tin foil hat, and verify that. */
hsv_to_rgb(hue, saturation, value, &r, &g, &b);
ASSERT(r == 255);
ASSERT(g == 0);
ASSERT(b == 128);
not the tin foil hat π but fr fr that's the whole thing β round trip a color, then assert it came back identical. slay. π
π«Ά SEE ALSO π«Ά
ngl the tin foil hat line is iconic and i refuse to paraphrase it π
and that's the whole page bestie, mwah π β brought to you by Allegro, version 4.4.3. go forth and convert some colors, you main character. πβπ
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms