]> git.lizzy.rs Git - nothing.git/blobdiff - src/color.h
Implement chop_background_layer
[nothing.git] / src / color.h
index 67d5c72ee0783fbbad5fa55a62c6534312090b06..cffb7cf613f7e787d84fc6d76f58cb3447a27935 100644 (file)
@@ -1,15 +1,41 @@
 #ifndef COLOR_H_
 #define COLOR_H_
 
-typedef struct SDL_Color SDL_Color;
+#include <stdio.h>
+#include <SDL.h>
+#include "./system/s.h"
 
-typedef struct color_t {
+#define COLOR_BLACK rgba(0.0f, 0.0f, 0.0f, 1.0f)
+#define COLOR_WHITE rgba(1.0f, 1.0f, 1.0f, 1.0f)
+#define COLOR_RED rgba(1.0f, 0.0f, 0.0f, 1.0f)
+
+typedef struct Color {
     float r, g, b, a;
-} color_t;
+} Color;
+
+Color rgba(float r, float g, float b, float a);
+Color hsla(float h, float s, float l, float a);
+Color rgba_to_hsla(Color color);
+Color hexstr(const char *hexstr);
+Color hexs(String input);
+SDL_Color color_for_sdl(Color color);
+
+int color_hex_to_stream(Color color, FILE *stream);
+int color_hex_to_string(Color color, char *buffer, size_t buffer_size);
+
+Color color_darker(Color color, float d);
+
+Color color_desaturate(Color color);
+
+Color color_invert(Color c);
 
-color_t color(float r, float g, float b, float a);
-SDL_Color color_for_sdl(color_t color);
+Color color_scale(Color c, Color fc);
 
-color_t color_desaturate(color_t color);
+static inline
+Color color_set_alpha(Color c, float a)
+{
+    c.a = a;
+    return c;
+}
 
 #endif  // COLOR_H_