aboutsummaryrefslogtreecommitdiff
path: root/host/color.h
blob: 2a9d345ef9027f53899b4fadda2c79ae00c02b51 (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 <stdlib.h>

/* For easier memsetting we use an inverted alpha channel, i.e. 0 ≘ fully opaque; 255 ≘ fully transparent */
typedef struct {
	uint8_t r, g, b, a;
} color_t;

typedef struct {
	uint8_t r, g, b;
} rgb_t;

typedef struct {
	color_t *data;
	size_t w;
	size_t h;
} framebuffer_t;

int xterm_color_index(color_t c);

/* gray */
#define DEFAULT_FG_COLOR 7
/* black */
#define DEFAULT_BG_COLOR 0

extern color_t colortable[256];
static inline void framebuffer_free(framebuffer_t *fb){
	if(fb)
		free(fb->data);
	free(fb);
}

#endif//__COLOR_H__