Convert extra "moveto" coordinates to "lineto" commands.

Per the [SVG spec](http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands):

> If a moveto is followed by multiple pairs of coordinates, the
> subsequent pairs are treated as implicit lineto commands. Hence,
> implicit lineto commands will be relative if the moveto is relative,
> and absolute if the moveto is absolute."
This commit is contained in:
Jim Rodovich 2014-05-30 10:08:03 -05:00
parent bda5ab8611
commit 6f8444c86a

View file

@ -18,6 +18,10 @@
q: 4,
t: 2,
a: 7
},
repeatedCommands = {
m: 'l',
M: 'L'
};
if (fabric.Path) {
@ -586,12 +590,14 @@
}
}
var command = coordsParsed[0].toLowerCase(),
commandLength = commandLengths[command];
var command = coordsParsed[0],
commandLength = commandLengths[command.toLowerCase()],
repeatedCommand = repeatedCommands[command] || command;
if (coordsParsed.length - 1 > commandLength) {
for (var k = 1, klen = coordsParsed.length; k < klen; k += commandLength) {
result.push([ coordsParsed[0] ].concat(coordsParsed.slice(k, k + commandLength)));
result.push([ command ].concat(coordsParsed.slice(k, k + commandLength)));
command = repeatedCommand;
}
}
else {