mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-25 21:53:44 +00:00
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:
parent
bda5ab8611
commit
6f8444c86a
1 changed files with 9 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue