@@ -546,6 +546,9 @@ protected void parsePath() {
546546// char prevCommand = '\0';
547547 boolean prevCurve = false ;
548548 float ctrlX , ctrlY ;
549+ // store values for closepath so that relative coords work properly
550+ float movetoX = 0 ;
551+ float movetoY = 0 ;
549552
550553 while (i < pathTokens .length ) {
551554 char c = pathTokens [i ].charAt (0 );
@@ -560,6 +563,8 @@ protected void parsePath() {
560563 case 'M' : // M - move to (absolute)
561564 cx = PApplet .parseFloat (pathTokens [i + 1 ]);
562565 cy = PApplet .parseFloat (pathTokens [i + 2 ]);
566+ movetoX = cx ;
567+ movetoY = cy ;
563568 parsePathMoveto (cx , cy );
564569 implicitCommand = 'L' ;
565570 i += 3 ;
@@ -798,6 +803,11 @@ protected void parsePath() {
798803
799804 case 'Z' :
800805 case 'z' :
806+ // since closing the path, the 'current' point needs
807+ // to return back to the last moveto location.
808+ // http://code.google.com/p/processing/issues/detail?id=1058
809+ cx = movetoX ;
810+ cy = movetoY ;
801811 close = true ;
802812 i ++;
803813 break ;
@@ -811,7 +821,7 @@ protected void parsePath() {
811821 System .err .println ("unparsed: " + unparsed );
812822 if (pathTokens [i ].equals ("a" ) || pathTokens [i ].equals ("A" )) {
813823 String msg = "Sorry, elliptical arc support for SVG files " +
814- "is not yet implemented (See issue # 130 for updates)" ;
824+ "is not yet implemented (See issue 130 for updates)" ;
815825 throw new RuntimeException (msg );
816826 }
817827 throw new RuntimeException ("shape command not handled: " + pathTokens [i ]);
0 commit comments