aboutsummaryrefslogtreecommitdiff
path: root/src/color.h
blob: a2f82d3dc508ea066dcba5cde313a31e632a9561 (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
35
36
#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
#define COLOR_FG	1
#define COLOR_BG	2

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

	char *no;
};

extern struct console_color colors[ _COLORS_SIZE ];

//Calculate luminance
//Order LSB first: BGR
uint8_t rgb_luminance(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, uint8_t _mode);

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