@@ -554,6 +554,9 @@ protected void parsePath() {
554554// char prevCommand = '\0';
555555 boolean prevCurve = false ;
556556 float ctrlX , ctrlY ;
557+ // store values for closepath so that relative coords work properly
558+ float movetoX = 0 ;
559+ float movetoY = 0 ;
557560
558561 while (i < pathTokens .length ) {
559562 char c = pathTokens [i ].charAt (0 );
@@ -568,6 +571,8 @@ protected void parsePath() {
568571 case 'M' : // M - move to (absolute)
569572 cx = PApplet .parseFloat (pathTokens [i + 1 ]);
570573 cy = PApplet .parseFloat (pathTokens [i + 2 ]);
574+ movetoX = cx ;
575+ movetoY = cy ;
571576 parsePathMoveto (cx , cy );
572577 implicitCommand = 'L' ;
573578 i += 3 ;
@@ -654,15 +659,15 @@ protected void parsePath() {
654659 break ;
655660
656661 // S - curve to shorthand (absolute)
657- // Draws a cubic Bezier curve from the current point to (x,y). The first
662+ // Draws a cubic Bézier curve from the current point to (x,y). The first
658663 // control point is assumed to be the reflection of the second control
659664 // point on the previous command relative to the current point.
660665 // (x2,y2) is the second control point (i.e., the control point
661666 // at the end of the curve). S (uppercase) indicates that absolute
662667 // coordinates will follow; s (lowercase) indicates that relative
663668 // coordinates will follow. Multiple sets of coordinates may be specified
664- // to draw a polybezier . At the end of the command, the new current point
665- // becomes the final (x,y) coordinate pair used in the polybezier .
669+ // to draw a polybézier . At the end of the command, the new current point
670+ // becomes the final (x,y) coordinate pair used in the polybézier .
666671 case 'S' : {
667672 // (If there is no previous command or if the previous command was not
668673 // an C, c, S or s, assume the first control point is coincident with
@@ -716,12 +721,12 @@ protected void parsePath() {
716721 break ;
717722
718723 // Q - quadratic curve to (absolute)
719- // Draws a quadratic Bezier curve from the current point to (x,y) using
724+ // Draws a quadratic Bézier curve from the current point to (x,y) using
720725 // (x1,y1) as the control point. Q (uppercase) indicates that absolute
721726 // coordinates will follow; q (lowercase) indicates that relative
722727 // coordinates will follow. Multiple sets of coordinates may be specified
723- // to draw a polybezier . At the end of the command, the new current point
724- // becomes the final (x,y) coordinate pair used in the polybezier .
728+ // to draw a polybézier . At the end of the command, the new current point
729+ // becomes the final (x,y) coordinate pair used in the polybézier .
725730 case 'Q' : {
726731 ctrlX = PApplet .parseFloat (pathTokens [i + 1 ]);
727732 ctrlY = PApplet .parseFloat (pathTokens [i + 2 ]);
@@ -806,6 +811,11 @@ protected void parsePath() {
806811
807812 case 'Z' :
808813 case 'z' :
814+ // since closing the path, the 'current' point needs
815+ // to return back to the last moveto location.
816+ // http://code.google.com/p/processing/issues/detail?id=1058
817+ cx = movetoX ;
818+ cy = movetoY ;
809819 close = true ;
810820 i ++;
811821 break ;
@@ -819,7 +829,7 @@ protected void parsePath() {
819829 System .err .println ("unparsed: " + unparsed );
820830 if (pathTokens [i ].equals ("a" ) || pathTokens [i ].equals ("A" )) {
821831 String msg = "Sorry, elliptical arc support for SVG files " +
822- "is not yet implemented (See issue # 130 for updates)" ;
832+ "is not yet implemented (See issue 130 for updates)" ;
823833 throw new RuntimeException (msg );
824834 }
825835 throw new RuntimeException ("shape command not handled: " + pathTokens [i ]);
0 commit comments