color.c utils

This commit is contained in:
randy 2024-07-02 12:48:05 +07:00
parent b2758db850
commit f66e89087e
2 changed files with 12 additions and 1 deletions

11
oogabooga/color.c Normal file
View file

@ -0,0 +1,11 @@
// usage example: hex_to_rgba(0x2a2d3aff);
Vector4 hex_to_rgba(s64 hex) {
u8 r = (hex>>24) & 0x000000FF;
u8 g = (hex>>16) & 0x000000FF;
u8 b = (hex>>8) & 0x000000FF;
u8 a = (hex>>0) & 0x000000FF;
return (Vector4){r/255.0, g/255.0, b/255.0, a/255.0};
}
// todo - hsv conversion stuff when it's needed

View file

@ -134,7 +134,7 @@ void lodepng_free(void* ptr) {
#endif #endif
#include "random.c" #include "random.c"
#include "color.c"
#include "memory.c" #include "memory.c"
#include "input.c" #include "input.c"