From f14acf7306b022c1d0dd98f5fd654dbdc38e64e5 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 22 Apr 2023 18:40:22 +0200 Subject: create ffbg --- drw.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 drw.h (limited to 'drw.h') diff --git a/drw.h b/drw.h new file mode 100644 index 0000000..37e44c9 --- /dev/null +++ b/drw.h @@ -0,0 +1,45 @@ +#ifndef DRW_H +#define DRW_H + +#include +#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 -- cgit v1.2.3-70-g09d2