aboutsummaryrefslogtreecommitdiff
path: root/drw.h
blob: 37e44c9e403eea8fbc0fdef74ffcedd797b1e069 (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
37
38
39
40
41
42
43
44
45
#ifndef DRW_H
#define DRW_H

#include <stdint.h>
#include "wayland.h"

/* type definitions */
typedef struct {
	uint32_t *data;
	unsigned width;
	unsigned height;
	unsigned size;
	struct wl_buffer *buffer;
} Canvas;

typedef struct {
	uint8_t r;
	uint8_t g;
	uint8_t b;
	uint8_t a;
} Color;

/* exported functions */
Canvas* create_drw(struct wl_shm *shm, unsigned width, unsigned height);
void free_drw(Canvas *canvas);

void draw_rect(Canvas *canvas, unsigned x, unsigned y, unsigned width, unsigned height, uint32_t color);
void draw_point(Canvas *canvas, unsigned x, unsigned y, uint32_t color);



static Color
to_color(uint32_t color)
{
	return *(Color*)(&color);
}


static uint32_t
to_uint32_t(Color color)
{
	return *(uint32_t*)(&color);
}

#endif