aboutsummaryrefslogtreecommitdiff
path: root/subprojects/d2tk/example/custom_cairo.c
blob: 56904ed521528fc593520c0ece9d36a8fa44d807 (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
#include <stdint.h>

#include <d2tk/core.h>

#include <cairo.h>

static void
_draw_custom(void *_ctx, const d2tk_rect_t *rect, const void *data)
{
	cairo_t *ctx = _ctx;
	(void)data;

	d2tk_rect_t bnd = *rect;
	bnd.x += bnd.w/4;
	bnd.y += bnd.h/4;
	bnd.w /= 2;
	bnd.h /= 2;

	cairo_new_sub_path(ctx);
	cairo_rectangle(ctx, bnd.x, bnd.y, bnd.w, bnd.h);
	cairo_set_source_rgba(ctx, 1.f, 1.f, 1.f, 0.5f);
	cairo_fill(ctx);
}

d2tk_core_custom_t draw_custom = _draw_custom;