From: Jean-Philippe Bruyère Date: Tue, 30 Nov 2021 07:26:44 +0000 (+0100) Subject: quadratic debug X-Git-Tag: v0.2.0~48 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=7061ed98972faaa12f90a5b4d732a785038c3f35;p=jp%2Fvkvg.git quadratic debug --- diff --git a/src/vkvg_context.c b/src/vkvg_context.c index c53369c..674a031 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -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)