]> O.S.I.I.S - jp/vkvg.git/commitdiff
quadratic debug
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 30 Nov 2021 07:26:44 +0000 (08:26 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 30 Nov 2021 07:26:44 +0000 (08:26 +0100)
src/vkvg_context.c

index c53369c3a041141fbe993a24bb733dfc2ab32782..674a03134b4ad4f9147bba24b3967b4f03d8be78 100644 (file)
@@ -466,21 +466,23 @@ void vkvg_rel_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float
        vec2 cp = _get_current_position(ctx);
        vkvg_quadratic_to (ctx, cp.x + x1, cp.y + y1, cp.x + x2, cp.y + y2);
 }
+const double quadraticFact = 2.0/3.0;
 void vkvg_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float y2) {
        if (ctx->status)
                return;
-       _set_curve_start (ctx);
-       if (_current_path_is_empty(ctx))
-               _add_point(ctx, x1, y1);
+
        float x0, y0;
-       vkvg_get_current_point (ctx, &x0, &y0);
+       if (_current_path_is_empty(ctx)) {
+               x0 = x1;
+               y0 = y1;
+       } else
+               vkvg_get_current_point (ctx, &x0, &y0);
        vkvg_curve_to (ctx,
-                                 2.0 / 3.0 * x1 + 1.0 / 3.0 * x0,
-                                 2.0 / 3.0 * y1 + 1.0 / 3.0 * y0,
-                                 2.0 / 3.0 * x1 + 1.0 / 3.0 * x2,
-                                 2.0 / 3.0 * y1 + 1.0 / 3.0 * y2,
-                                 y1, y2);
-       _set_curve_end (ctx);
+                                       x0 + (x1 - x0) * quadraticFact,
+                                       y0 + (y1 - y0) * quadraticFact,
+                                       x2 + (x1 - x2) * quadraticFact,
+                                       y2 + (y1 - y2) * quadraticFact,
+                                       x2, y2);
 }
 void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) {
        if (ctx->status)