From 7950d296f0ee40ed3568e7e448bce378ad7392b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Fri, 20 Apr 2018 05:56:37 +0200 Subject: [PATCH] simplify line cap algo --- src/vkvg_context.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/vkvg_context.c b/src/vkvg_context.c index b81f72e..efc7234 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -408,14 +408,8 @@ void vkvg_stroke_preserve (VkvgContext ctx) if (ctx->lineCap == VKVG_LINE_CAP_ROUND){ float step = M_PI_2 / hw; float a = acos(n.x) + M_PI_2; - if (n.y < 0){ - a = asin(n.y); - if (n.x < 0) - a = acos(-n.x) -M_PI_2; - else - a += M_PI_2; - } - + if (n.y < 0) + a = M_PI-a; float a1 = a + M_PI; a+=step; @@ -461,15 +455,10 @@ void vkvg_stroke_preserve (VkvgContext ctx) if (ctx->lineCap == VKVG_LINE_CAP_ROUND){ firstIdx = ctx->vertCount; - float step = M_PI_4 / hw; + float step = M_PI_2 / hw; float a = acos(n.x)+ M_PI_2; - if (n.y < 0){ - a = asin(n.y); - if (n.x < 0) - a = acos(-n.x) -M_PI_2; - else - a += M_PI_2; - } + if (n.y < 0) + a = M_PI-a; float a1 = a - M_PI; a-=step; while ( a > a1){ @@ -477,9 +466,6 @@ void vkvg_stroke_preserve (VkvgContext ctx) a-=step; } - //printf("x = %f; y = %f ; acos(n.x)=%f ; ", n.x, n.y, acos(n.x)); - //printf("sin(acos(n.x))=%f ; \n", (acos(n.x))); - uint32_t p0Idx = ctx->vertCount-1; for (int p = firstIdx-1 ; p < p0Idx; p++) _add_triangle_indices(ctx, p+1, p, firstIdx-2); -- 2.47.3