From a12c158ad4676473c52c08a9e871af4b96743c65 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Thu, 16 Dec 2021 18:51:09 +0000 Subject: [PATCH] Add more shapes to the canvas demo --- demo/canvas.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/demo/canvas.c b/demo/canvas.c index 30b76da..6c50bcb 100644 --- a/demo/canvas.c +++ b/demo/canvas.c @@ -60,7 +60,7 @@ canvas(struct nk_context *ctx) nk_fill_rect(canvas.painter, nk_rect(x + 250, y + 20, 100, 100), 0, nk_rgb(0,0,255)); nk_fill_circle(canvas.painter, nk_rect(x + 20, y + 250, 100, 100), nk_rgb(255,0,0)); nk_fill_triangle(canvas.painter, x + 250, y + 250, x + 350, y + 250, x + 300, y + 350, nk_rgb(0,255,0)); - nk_fill_arc(canvas.painter, x + 300, y + 180, 50, 0, 3.141592654f * 3.0f / 4.0f, nk_rgb(255,255,0)); + nk_fill_arc(canvas.painter, x + 300, y + 420, 50, 0, 3.141592654f * 3.0f / 4.0f, nk_rgb(255,255,0)); { float points[12]; @@ -73,11 +73,32 @@ canvas(struct nk_context *ctx) nk_fill_polygon(canvas.painter, points, 6, nk_rgb(0,0,0)); } + { + float points[12]; + points[0] = x + 200; points[1] = y + 370; + points[2] = x + 250; points[3] = y + 470; + points[4] = x + 225; points[5] = y + 470; + points[6] = x + 200; points[7] = y + 420; + points[8] = x + 175; points[9] = y + 470; + points[10] = x + 150; points[11] = y + 470; + nk_stroke_polygon(canvas.painter, points, 6, 4, nk_rgb(0,0,0)); + } + + { + float points[8]; + points[0] = x + 250; points[1] = y + 200; + points[2] = x + 275; points[3] = y + 220; + points[4] = x + 325; points[5] = y + 170; + points[6] = x + 350; points[7] = y + 200; + nk_stroke_polyline(canvas.painter, points, 4, 2, nk_rgb(255,128,0)); + } + nk_stroke_line(canvas.painter, x + 15, y + 10, x + 200, y + 10, 2.0f, nk_rgb(189,45,75)); nk_stroke_rect(canvas.painter, nk_rect(x + 370, y + 20, 100, 100), 10, 3, nk_rgb(0,0,255)); nk_stroke_curve(canvas.painter, x + 380, y + 200, x + 405, y + 270, x + 455, y + 120, x + 480, y + 200, 2, nk_rgb(0,150,220)); nk_stroke_circle(canvas.painter, nk_rect(x + 20, y + 370, 100, 100), 5, nk_rgb(0,255,120)); nk_stroke_triangle(canvas.painter, x + 370, y + 250, x + 470, y + 250, x + 420, y + 350, 6, nk_rgb(255,0,143)); + nk_stroke_arc(canvas.painter, x + 420, y + 420, 50, 0, 3.141592654f * 3.0f / 4.0f, 5, nk_rgb(0,255,255)); } canvas_end(ctx, &canvas); }