From 2d4778138a960940b3befd419e1a42af132f5d4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 27 Aug 2020 05:10:58 +0200 Subject: [PATCH] check that all points of curve are not equal before calling recursive_bezier --- src/vkvg_context.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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]); } -- 2.47.3