aboutsummaryrefslogtreecommitdiff
path: root/subprojects/d2tk/example/custom_nanovg.c
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/d2tk/example/custom_nanovg.c')
-rw-r--r--subprojects/d2tk/example/custom_nanovg.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/subprojects/d2tk/example/custom_nanovg.c b/subprojects/d2tk/example/custom_nanovg.c
new file mode 100644
index 0000000..7bd2db3
--- /dev/null
+++ b/subprojects/d2tk/example/custom_nanovg.c
@@ -0,0 +1,28 @@
+#include <stdint.h>
+#include <math.h>
+
+#include <d2tk/core.h>
+
+#include <nanovg.h>
+
+static void
+_draw_custom(void *_ctx, const d2tk_rect_t *rect, const void *data)
+{
+ NVGcontext *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;
+
+ const NVGcolor col = nvgRGBA(0xff, 0xff, 0xff, 0x7f);
+
+ nvgBeginPath(ctx);
+ nvgRect(ctx, bnd.x, bnd.y, bnd.w, bnd.h);
+ nvgFillColor(ctx, col);
+ nvgFill(ctx);
+}
+
+d2tk_core_custom_t draw_custom = _draw_custom;