Skip to content

Commit

Permalink
Added the operation 0x0C to draw rounded rectangles with varying radi…
Browse files Browse the repository at this point in the history
…us corners.
  • Loading branch information
GPrimola committed Sep 8, 2022
1 parent bc924a7 commit dc6ebcc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions c_src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ script_t* get_script( sid_t id ) {
&scripts,
_comparator,
&id,
HASH_ID( id )
HASH_ID( id )
);
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
);
Expand Down Expand Up @@ -638,4 +650,3 @@ void render_script( sid_t id, NVGcontext* p_ctx ) {
nvgRestore( p_ctx );
}
}

0 comments on commit dc6ebcc

Please sign in to comment.