Browse Source

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
pull/8/head
Mikko Mononen 9 years ago
parent
commit
297c2d5252
  1. 4
      example/main.c
  2. 5
      src/nanosvg.h

4
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);

5
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);

Loading…
Cancel
Save