]> git.lizzy.rs Git - nothing.git/blob - src/color.h
937782256b1057093ed08d4501ed89120654c91a
[nothing.git] / src / color.h
1 #ifndef COLOR_H_
2 #define COLOR_H_
3
4 #include <stdio.h>
5 #include <SDL.h>
6
7 #define COLOR_BLACK rgba(0.0f, 0.0f, 0.0f, 1.0f)
8 #define COLOR_WHITE rgba(1.0f, 1.0f, 1.0f, 1.0f)
9 #define COLOR_RED rgba(1.0f, 0.0f, 0.0f, 1.0f)
10
11 typedef struct Color {
12     float r, g, b, a;
13 } Color;
14
15 Color rgba(float r, float g, float b, float a);
16 Color hsla(float h, float s, float l, float a);
17 Color rgba_to_hsla(Color color);
18 Color hexstr(const char *hexstr);
19 SDL_Color color_for_sdl(Color color);
20
21 int color_hex_to_stream(Color color, FILE *stream);
22 int color_hex_to_string(Color color, char *buffer, size_t buffer_size);
23
24 Color color_darker(Color color, float d);
25
26 Color color_desaturate(Color color);
27
28 Color color_invert(Color c);
29
30 Color color_scale(Color c, Color fc);
31
32 static inline
33 Color color_set_alpha(Color c, float a)
34 {
35     c.a = a;
36     return c;
37 }
38
39 #endif  // COLOR_H_