From 297c2d5252980e285a961e87617c8471c9836ede Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Thu, 2 Jan 2014 20:43:27 +0200 Subject: [PATCH] Fixed issue #3 - added missing break after 'm'/'M' path command - path command 'm'/'M' is converted to 'l'/'L' so that multiple coordinate pairs behave correctly - fixed rendering of first point on path --- example/main.c | 4 ++-- src/nanosvg.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/example/main.c b/example/main.c index d290dc2..dfc8c93 100644 --- a/example/main.c +++ b/example/main.c @@ -138,8 +138,8 @@ void drawControlPts(float* pts, int npts, char closed) glPointSize(6.0f); glColor4ubv(lineColor); - glVertex2f(pts[0],pts[1]); glBegin(GL_POINTS); + glVertex2f(pts[0],pts[1]); for (i = 0; i < npts-1; i += 3) { float* p = &pts[i*2]; glVertex2f(p[6],p[7]); @@ -149,9 +149,9 @@ void drawControlPts(float* pts, int npts, char closed) // Points glPointSize(3.0f); + glBegin(GL_POINTS); glColor4ubv(bgColor); glVertex2f(pts[0],pts[1]); - glBegin(GL_POINTS); for (i = 0; i < npts-1; i += 3) { float* p = &pts[i*2]; glColor4ubv(lineColor); diff --git a/src/nanosvg.h b/src/nanosvg.h index d27a209..0542d80 100644 --- a/src/nanosvg.h +++ b/src/nanosvg.h @@ -1399,6 +1399,11 @@ static void nsvg__parsePath(struct NSVGParser* p, const char** attr) case 'm': case 'M': nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0); + // Moveto can be followed by multiple coordinate pairs, + // which should be treated as linetos. + cmd = (cmd =='m') ? 'l' : 'L'; + rargs = nsvg__getArgsPerElement(cmd); + break; case 'l': case 'L': nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0);