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