LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
color.c
Go to the documentation of this file.
1
9#include <lib/color.h>
10
12struct rgb get_rgb(uint8_t r, uint8_t g, uint8_t b) {
13 struct rgb rgb;
14
15 rgb.r = r;
16 rgb.g = g;
17 rgb.b = b;
18
19 return rgb;
20}
21
22struct rgb add_rgb(struct rgb a, struct rgb b) {
23 struct rgb rgb;
24
25 rgb.r = (a.r + b.r > 255) ? 255 : a.r + b.r;
26 rgb.g = (a.g + b.g > 255) ? 255 : a.g + b.g;
27 rgb.b = (a.b + b.b > 255) ? 255 : a.b + b.b;
28
29 return rgb;
30}
31
32struct rgb sub_rgb(struct rgb a, struct rgb b) {
33 struct rgb rgb;
34
35 rgb.r = (a.r < b.r) ? 0 : a.r - b.r;
36 rgb.g = (a.g < b.g) ? 0 : a.g - b.g;
37 rgb.b = (a.b < b.b) ? 0 : a.b - b.b;
38
39 return rgb;
40}
Color utilities.
struct rgb add_rgb(struct rgb a, struct rgb b)
Adds two RGB color values.
Definition color.c:22
struct rgb get_rgb(uint8_t r, uint8_t g, uint8_t b)
Creates an RGB color value from the 3 separate colors.
Definition color.c:12
struct rgb sub_rgb(struct rgb a, struct rgb b)
Subtracts the second RGB color from the first.
Definition color.c:32
RGB color values.
Definition color.h:15