From: Jean-Philippe Bruyère Date: Sun, 5 May 2019 23:40:22 +0000 (+0200) Subject: increase arc resolution X-Git-Tag: v0.1-alpha~75 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=4ac2d4dea5c520b0222cb333239fa688a16e51ff;p=jp%2Fvkvg.git increase arc resolution --- diff --git a/src/vkvg_context.c b/src/vkvg_context.c index b6c568f..8dc1366 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -326,7 +326,7 @@ void vkvg_arc (VkvgContext ctx, float xc, float yc, float radius, float a1, floa vec2 v = {cosf(a1)*radius + xc, sinf(a1)*radius + yc}; - float step = M_PIF/radius*1.5f; + float step = M_PIF/radius*0.5f; float a = a1; if (_current_path_is_empty(ctx)) @@ -345,8 +345,10 @@ void vkvg_arc (VkvgContext ctx, float xc, float yc, float radius, float a1, floa _add_point (ctx, v.x, v.y); a+=step; } - if (EQUF(a2-a1,M_PIF*2.f))//if arc is complete circle, last point is the same as the first one + if (EQUF(a2-a1,M_PIF*2.f)){//if arc is complete circle, last point is the same as the first one + vkvg_close_path(ctx); return; + } a = a2; vec2 lastP = v; v.x = cosf(a)*radius + xc; diff --git a/tests/arcs.c b/tests/arcs.c new file mode 100644 index 0000000..3d10c35 --- /dev/null +++ b/tests/arcs.c @@ -0,0 +1,25 @@ +#include "test.h" + +void test(){ + VkvgContext ctx = vkvg_create(surf); + + vkvg_set_line_width(ctx, 0.5); + vkvg_set_source_rgb (ctx, 1,1,1); + vkvg_paint(ctx); + vkvg_set_source_rgb (ctx, 0,0,0); + + vkvg_scale(ctx,3,3); + vkvg_arc(ctx, 150, 100, 3.5, 0, M_PI*2); + vkvg_stroke(ctx); + vkvg_arc(ctx, 200, 200, 10, 0, M_PI*2); + vkvg_fill(ctx); + + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + + perform_test (test, 1024, 768); + + return 0; +}