diff --git a/samples/canvas/main.um b/samples/canvas/main.um index b9bcab9..d96bd26 100644 --- a/samples/canvas/main.um +++ b/samples/canvas/main.um @@ -9,5 +9,6 @@ fn init*() { window::onFrame.register({ canvas::drawRectLines(0x000000FF, {30, 30, 100, 100}, 3) canvas::drawRectLines(0xFF000066, {80, 80, 100, 110}, 5) + canvas::drawTrig(0x00FF0066, { 30, 200 }, { 120, 200 }, { 30, 300 }) }) } diff --git a/src/bindings.c b/src/bindings.c index 70f2cac..620ad72 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -1254,6 +1254,18 @@ umth_canvas_draw_quad(UmkaStackSlot *p, UmkaStackSlot *r) th_canvas_quad(q, color); } +// fn umth_canvas_draw_trig(color: uint32, a, b, c: th::Vf2) +void +umth_canvas_draw_trig(UmkaStackSlot *p, UmkaStackSlot *r) +{ + uint32_t color = umkaGetParam(p, 0)->uintVal; + th_vf2 a = *(th_vf2 *)umkaGetParam(p, 1); + th_vf2 b = *(th_vf2 *)umkaGetParam(p, 2); + th_vf2 c = *(th_vf2 *)umkaGetParam(p, 3); + + th_canvas_triangle(color, a, b, c); +} + // fn umth_canvas_begin_scissor_rect(r: rect::Rect) void umth_canvas_begin_scissor_rect(UmkaStackSlot *p, UmkaStackSlot *r) @@ -1593,6 +1605,7 @@ _th_umka_bind(void *umka) umkaAddFunc(umka, "umth_canvas_draw_line", &umth_canvas_draw_line); umkaAddFunc(umka, "umth_canvas_draw_rect_lines", &umth_canvas_draw_rect_lines); umkaAddFunc(umka, "umth_canvas_draw_quad", &umth_canvas_draw_quad); + umkaAddFunc(umka, "umth_canvas_draw_trig", &umth_canvas_draw_trig); umkaAddFunc(umka, "umth_canvas_begin_scissor_rect", &umth_canvas_begin_scissor_rect); umkaAddFunc(umka, "umth_canvas_end_scissor", &umth_canvas_end_scissor); diff --git a/src/staembed.c b/src/staembed.c index 425c0ee..1475945 100644 --- a/src/staembed.c +++ b/src/staembed.c @@ -1312,6 +1312,14 @@ const char *th_em_modulesrc[] = { "\tumth_canvas_draw_quad(color, q)\n" "}\n" "\n" +"fn umth_canvas_draw_trig(color: uint32, a, b, c: th::Vf2)\n" +"//~~fn drawTrig\n" +"// Draws a triangle.\n" +"fn drawTrig*(color: uint32, a, b, c: th::Vf2) {\n" +"//~~\n" +"\tumth_canvas_draw_trig(color, a, b, c)\n" +"}\n" +"\n" "var scissor: []rect::Rect\n" "\n" "fn umth_canvas_begin_scissor_rect(r: rect::Rect)\n" @@ -5073,6 +5081,14 @@ const char *th_em_moduledocs[] = { "\n" "---------\n" "\n" +"fn drawTrig\n" +"\n" +"fn drawTrig*(color: uint32, a, b, c: th::Vf2) {\n" +"\n" +"Draws a triangle.\n" +"\n" +"---------\n" +"\n" "fn beginScissorRect\n" "\n" "fn beginScissorRect*(r: rect::Rect, debug: bool = false) {\n" diff --git a/umka/canvas.um b/umka/canvas.um index 0c2a511..5ed0eec 100644 --- a/umka/canvas.um +++ b/umka/canvas.um @@ -98,6 +98,14 @@ fn drawQuad*(color: uint32, q: th::Quad) { umth_canvas_draw_quad(color, q) } +fn umth_canvas_draw_trig(color: uint32, a, b, c: th::Vf2) +//~~fn drawTrig +// Draws a triangle. +fn drawTrig*(color: uint32, a, b, c: th::Vf2) { +//~~ + umth_canvas_draw_trig(color, a, b, c) +} + var scissor: []rect::Rect fn umth_canvas_begin_scissor_rect(r: rect::Rect)