]> git.lizzy.rs Git - nothing.git/blob - src/color.c
Add color module (#93)
[nothing.git] / src / color.c
1 #include <SDL2/SDL.h>
2
3 #include "./color.h"
4
5 color_t color(float r, float g, float b, float a)
6 {
7     const color_t result = {
8         .r = r,
9         .g = g,
10         .b = b,
11         .a = a
12     };
13
14     return result;
15 }
16
17 SDL_Color color_for_sdl(color_t color)
18 {
19     const SDL_Color result = {
20         .r = (Uint8)roundf(color.r * 255.0f),
21         .g = (Uint8)roundf(color.g * 255.0f),
22         .b = (Uint8)roundf(color.b * 255.0f),
23         .a = (Uint8)roundf(color.a * 255.0f)
24     };
25
26     return result;
27 }