From dace7dca77e9539b5cb459f79c1154d11b3030fe Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 23 Mar 2023 20:28:57 +0100 Subject: first version of wlock --- drw.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 drw.h (limited to 'drw.h') diff --git a/drw.h b/drw.h new file mode 100644 index 0000000..2dab93d --- /dev/null +++ b/drw.h @@ -0,0 +1,46 @@ +#ifndef DRW_H +#define DRW_H + +#include +#include +#include FT_FREETYPE_H +#include FT_BITMAP_H + +#include "wayland.h" + +/* type definitions */ +typedef struct { + uint32_t *tmp_data; + uint32_t *data; + unsigned width; + unsigned height; + uint64_t size; + struct wl_buffer *buffer; +} Canvas; + +typedef struct { + FT_Library library; + FT_Face face; +} Font; + +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 drw_push(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); + +Font* create_font(const char *fontpath, unsigned size); +void free_font(Font *font); +unsigned draw_font(Canvas *canvas, Font *font, const char *text, unsigned x, unsigned y, uint32_t color); +unsigned font_width(Font *font, const char *text); + +#endif -- cgit v1.2.3-70-g09d2