mirror of
https://github.com/IllusionMan1212/C2048.git
synced 2026-10-24 02:12:31 +00:00
WIP: settings, color picker and stuff
This commit is contained in:
@@ -84,3 +84,26 @@ Color mult_color(Color color, float amount) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Color hsv2rgb(float h, float s, float v) {
|
||||
float c = v * s;
|
||||
float x = (float)(c * (1 - fabs(fmod(h / 60.0, 2) - 1)));
|
||||
float m = v - c;
|
||||
|
||||
float r, g, b;
|
||||
|
||||
if (h >= 0 && h < 60) {
|
||||
r = c, g = x, b = 0;
|
||||
} else if (h >= 60 && h < 120) {
|
||||
r = x, g = c, b = 0;
|
||||
} else if (h >= 120 && h < 180) {
|
||||
r = 0, g = c, b = x;
|
||||
} else if (h >= 180 && h < 240) {
|
||||
r = 0, g = x, b = c;
|
||||
} else if (h >= 240 && h < 300) {
|
||||
r = x, g = 0, b = c;
|
||||
} else {
|
||||
r = c, g = 0, b = x;
|
||||
}
|
||||
|
||||
return (Color){(u8)((r + m) * 255), (u8)((g + m) * 255), (u8)((b + m) * 255), 255};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user