From: Jean-Philippe Bruyère Date: Thu, 27 Aug 2020 03:10:58 +0000 (+0200) Subject: check that all points of curve are not equal before calling recursive_bezier X-Git-Tag: v0.2.0~103 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=2d4778138a960940b3befd419e1a42af132f5d4a;p=jp%2Fvkvg.git check that all points of curve are not equal before calling recursive_bezier --- diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 2ba3bee..2e4139c 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -497,6 +497,11 @@ void vkvg_move_to (VkvgContext ctx, float x, float y) } void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) { + //prevent running _recursive_bezier when all 4 curve points are equal + if (EQUF(x1,x2) && EQUF(x2,x3) && EQUF(y1,y2) && EQUF(y2,y3)) { + if (_current_path_is_empty(ctx) || (EQUF(_get_current_position(ctx).x,x1) && EQUF(_get_current_position(ctx).y,y1))) + return; + } _set_curve_start (ctx); if (_current_path_is_empty(ctx)) _add_point(ctx, x1, y1); @@ -1270,7 +1275,7 @@ void vkvg_render_svg (VkvgContext ctx, NSVGimage* svg, char *subId){ for (path = shape->paths; path != NULL; path = path->next) { float* p = path->pts; vkvg_move_to(ctx, p[0],p[1]); - for (int i = 1; i < path->npts-2; i += 3) { + for (int i = 1; i < path->npts; i += 3) { p = &path->pts[i*2]; vkvg_curve_to(ctx, p[0],p[1], p[2],p[3], p[4],p[5]); }