From dc6ebcc6fdd7533c7ae94fde9be2cba313deea17 Mon Sep 17 00:00:00 2001 From: Gio Lucas Torres Date: Thu, 8 Sep 2022 14:28:49 -0300 Subject: [PATCH] Added the operation 0x0C to draw rounded rectangles with varying radius corners. --- c_src/script.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/c_src/script.c b/c_src/script.c index 758c13b..0a28222 100644 --- a/c_src/script.c +++ b/c_src/script.c @@ -56,7 +56,7 @@ script_t* get_script( sid_t id ) { &scripts, _comparator, &id, - HASH_ID( id ) + HASH_ID( id ) ); } @@ -368,6 +368,18 @@ void render_script( sid_t id, NVGcontext* p_ctx ) { case 0x0B: // draw_sprites i = render_sprites( p_ctx, p, i, param ); break; + case 0x0C: // draw_rrectv + nvgBeginPath(p_ctx); + nvgRoundedRectVarying(p_ctx, + 0, 0, + get_float(p, i), get_float(p, i + 4), + get_float(p, i + 8), get_float(p, i + 12), // Top left, Top Right + get_float(p, i + 16), get_float(p, i + 20) // Bottom right, Bottom left + ); + if (param & 1) nvgFill(p_ctx); + if (param & 2) nvgStroke(p_ctx); + i += 24; + break; case 0x0F: // render_script // we can reuse the passed in id struct @@ -452,7 +464,7 @@ void render_script( sid_t id, NVGcontext* p_ctx ) { case 0x50: // transform nvgTransform( p_ctx, - get_float(p, i), get_float(p, i+4), + get_float(p, i), get_float(p, i+4), get_float(p, i+8), get_float(p, i+12), get_float(p, i+16), get_float(p, i+20) ); @@ -638,4 +650,3 @@ void render_script( sid_t id, NVGcontext* p_ctx ) { nvgRestore( p_ctx ); } } -