diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-03-03 10:16:14 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-03-03 10:16:14 +0100 |
| commit | 827e2366ef8b0fe7bd8bc45f86ada15949e20da8 (patch) | |
| tree | 1d1ee214d982bf7ba0c61ccc2182f714dbc58b62 | |
| parent | bb9a717caeac10d28a96d501a31265fff208ceaf (diff) | |
solve tight angle curve by settings a curved join when dot<limit (0.8)curveparam2
| -rw-r--r-- | src/vkvg_context_internal.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 1a1ef73..76cd6f6 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -940,7 +940,7 @@ bool _build_vb_step (vkvg_context* ctx, float hw, stroke_context_t* str, bool is vec2 bisec_n_perp = vec2_perp(bisec_n); //limit bisectrice length - float rlh = lh; + float rlh = lh;//rlh is for inside pos tweeks if (dot < 0.f) rlh = fminf (rlh, fminf (length_v0, length_v1)); //--- @@ -977,8 +977,16 @@ bool _build_vb_step (vkvg_context* ctx, float hw, stroke_context_t* str, bool is } } + vkvg_line_join_t join = ctx->lineJoin; - if (ctx->lineJoin == VKVG_LINE_JOIN_MITER || isCurve){ + if (isCurve) { + if (dot < 0.8f) + join = VKVG_LINE_JOIN_ROUND; + else + join = VKVG_LINE_JOIN_MITER; + } + + if (join == VKVG_LINE_JOIN_MITER){ if (lh > str->lhMax) {//miter limit double x = (lh - str->lhMax) * cosf (halfAlpha); vec2 bisecPerp = vec2_mult_s (bisec_n, x); @@ -1051,7 +1059,7 @@ bool _build_vb_step (vkvg_context* ctx, float hw, stroke_context_t* str, bool is } _add_vertex(ctx, v); - if (ctx->lineJoin == VKVG_LINE_JOIN_BEVEL){ + if (join == VKVG_LINE_JOIN_BEVEL){ if (det<0){ _add_triangle_indices(ctx, idx, idx+2, idx+1); _add_triangle_indices(ctx, idx+2, idx+4, idx+0); @@ -1061,7 +1069,7 @@ bool _build_vb_step (vkvg_context* ctx, float hw, stroke_context_t* str, bool is _add_triangle_indices(ctx, idx+2, idx+3, idx+1); _add_triangle_indices(ctx, idx+1, idx+3, idx+4); } - }else if (ctx->lineJoin == VKVG_LINE_JOIN_ROUND){ + }else if (join == VKVG_LINE_JOIN_ROUND){ float step = M_PIF / hw; float a = acosf(vp.x); if (vp.y < 0) |