aboutsummaryrefslogtreecommitdiff
path: root/src/color.h
blob: 83d10f7a41c0d81f8f168296e34f4155923ae7ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef _COLOR_H_
#define _COLOR_H_

#include <stdint.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include "m.h"

#define _COLORS_SIZE 16u

struct console_color
{
	uint8_t R;
	uint8_t G;
	uint8_t B;

	char *no;
};

struct console_color colors[ _COLORS_SIZE ];

//Calculate luminance
//Order LSB first: BGR
uint8_t rgb_avg(uint8_t R, uint8_t G, uint8_t B);

//Get nearest printable color in console
char *calc_col(uint8_t R, uint8_t G, uint8_t B);

char *calc_col_ansi(uint8_t R, uint8_t G, uint8_t B);

char *calc_bg_col_ansi(uint8_t R, uint8_t G, uint8_t B);
#endif //_COLOR_H_