diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-03-20 15:21:21 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-03-20 15:21:21 +0100 |
| commit | 05e97f8346521b50fbedcc2e7d0679e297d4d98b (patch) | |
| tree | 6f0a909ffd1c5bcf5e1b95fa7ae61d721826e7db /drw.h | |
make first sketch of bar using freetype2 instead of cairo
Diffstat (limited to 'drw.h')
| -rw-r--r-- | drw.h | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -0,0 +1,44 @@ +#ifndef DRW_H +#define DRW_H + +#include <stdint.h> +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_BITMAP_H + +#include "wayland.h" + +/* type definitions */ +typedef struct { + uint32_t *data; + unsigned width; + unsigned height; + unsigned 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 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 |