summaryrefslogtreecommitdiff
path: root/src/core/color.c
blob: 4f1a877cca1bd04f540e7b53b2ce414bac263791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "vert.h"
#include "device.h"

Color32 COLOR32_WHITE = {1,1,1,1};

Color color32_tocolor(Color32* c) {
	return ssr_color(0xff * c->r, 0xff * c->g, 0xff * c->b, 0xff * c->a);
}

void color_tocolor32(Color c, Color32* out) {
	out->r = COLOR_R(c) / (float)0xff;
	out->g = COLOR_G(c) / (float)0xff;
	out->b = COLOR_B(c) / (float)0xff;
	out->a = COLOR_A(c) / (float)0xff;
}

void color32_saturate(Color32* c) {
	c->r = clamp(c->r, 0, 1);
	c->g = clamp(c->g, 0, 1);
	c->b = clamp(c->b, 0, 1);
	c->a = clamp(c->a, 0, 1);
}