diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-04-22 18:40:22 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-04-22 18:40:22 +0200 |
| commit | f14acf7306b022c1d0dd98f5fd654dbdc38e64e5 (patch) | |
| tree | 562e30fdad694f11fc1075b353be6d22d9094171 /drw.h | |
create ffbg
Diffstat (limited to 'drw.h')
| -rw-r--r-- | drw.h | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -0,0 +1,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 |