add implicit path commands to svg (bug #1503)

This commit is contained in:
benfry
2010-03-14 17:05:31 +00:00
parent f994c29dba
commit 136659ebbc
2 changed files with 21 additions and 2 deletions
+11 -1
View File
@@ -480,16 +480,25 @@ public class PShapeSVG extends PShape {
float cx = 0;
float cy = 0;
int i = 0;
char implicitCommand = '\0';
while (i < pathDataKeys.length) {
char c = pathDataKeys[i].charAt(0);
if(((c >= '0' && c <= '9') || (c == '-')) && implicitCommand != '\0') {
c = implicitCommand;
i--;
} else {
implicitCommand = c;
}
switch (c) {
case 'M': // M - move to (absolute)
cx = PApplet.parseFloat(pathDataKeys[i + 1]);
cy = PApplet.parseFloat(pathDataKeys[i + 2]);
parsePathMoveto(cx, cy);
implicitCommand = 'L';
i += 3;
break;
@@ -497,6 +506,7 @@ public class PShapeSVG extends PShape {
cx = cx + PApplet.parseFloat(pathDataKeys[i + 1]);
cy = cy + PApplet.parseFloat(pathDataKeys[i + 2]);
parsePathMoveto(cx, cy);
implicitCommand = 'l';
i += 3;
break;