From f66e89087e4ce568588a8567a8f83faa688ded57 Mon Sep 17 00:00:00 2001 From: randy Date: Tue, 2 Jul 2024 12:48:05 +0700 Subject: [PATCH] color.c utils --- oogabooga/color.c | 11 +++++++++++ oogabooga/oogabooga.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 oogabooga/color.c diff --git a/oogabooga/color.c b/oogabooga/color.c new file mode 100644 index 0000000..32616a6 --- /dev/null +++ b/oogabooga/color.c @@ -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 \ No newline at end of file diff --git a/oogabooga/oogabooga.c b/oogabooga/oogabooga.c index 2750017..987f560 100644 --- a/oogabooga/oogabooga.c +++ b/oogabooga/oogabooga.c @@ -134,7 +134,7 @@ void lodepng_free(void* ptr) { #endif #include "random.c" - +#include "color.c" #include "memory.c" #include "input.c"