]> O.S.I.I.S - jp/vkvg.git/commitdiff
increase arc resolution
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 5 May 2019 23:40:22 +0000 (01:40 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 5 May 2019 23:40:22 +0000 (01:40 +0200)
src/vkvg_context.c
tests/arcs.c [new file with mode: 0644]

index b6c568f497a8fad9502bdf7eadf9a1f4857b49b1..8dc1366bb80f13dddc76196c8ec48818b6b9f4ec 100644 (file)
@@ -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 (file)
index 0000000..3d10c35
--- /dev/null
@@ -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;
+}