gfx.h 1.68 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef GFX_H
#define GFX_H
#include "fonts.h"
#include "framebuffer.h"
#include <stddef.h>

struct gfx_region {
	struct framebuffer *fb;
	size_t x;
	size_t y;
	size_t width;
	size_t height;
};

void gfx_setpixel(struct gfx_region *r, int x, int y, Color c);
struct gfx_region gfx_screen(struct framebuffer *fb);
17
void gfx_putchar(const sFONT *font, struct gfx_region *reg, int x, int y, char ch,
18
						        Color fg, Color bg);
19
void gfx_puts(const sFONT *font, struct gfx_region *reg, int x, int y,
20
21
22
23
24
25
26
27
28
29
30
			   const char *str, Color fg, Color bg);
Color gfx_color_rgb_f(struct gfx_region *reg, float r, float g, float b);
Color gfx_color_rgb(struct gfx_region *reg, uint8_t r, uint8_t g, uint8_t b);
void gfx_clear_to_color(struct gfx_region *reg, Color c);
void gfx_clear(struct gfx_region *reg);
void gfx_circle(struct gfx_region *reg, int x, int y, int r, int t, Color c);
void gfx_circle_fill(struct gfx_region *reg, int x, int y, int r, Color c);
void gfx_rectangle(struct gfx_region *reg, int x, int y, int w, int h,
						      int t, Color c);
void gfx_rectangle_fill(struct gfx_region *reg, int x, int y, int w, int h,
								  Color c);
31
32
void gfx_line(struct gfx_region *reg, int x1, int y1, int x2, int y2,
						     int t, Color c);
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
void gfx_update(struct gfx_region *reg);

enum gfx_color {
	WHITE,
	BLACK,
	RED,
	GREEN,
	BLUE,
	YELLOW,

	COLORS
};

struct gfx_color_rgb {
	uint8_t r;
	uint8_t g;
	uint8_t b;
} extern const gfx_colors_rgb[COLORS];

Color gfx_color(struct gfx_region *reg, enum gfx_color color);

void gfx_copy_region_raw(struct gfx_region *reg, int x, int y, int w, int h,
					         size_t bpp, const void *p);
void gfx_copy_raw(struct gfx_region *reg, const void *p, size_t size);

#endif