Move start position after a close path (z) to the starting node of the path (previous M).

This commit is contained in:
Mario Minutolo
2013-11-25 12:19:02 +01:00
parent 88e9cdcbf7
commit e2f2c28b1b
2 changed files with 57 additions and 2 deletions

View File

@@ -295,9 +295,22 @@
// Note: lineTo handlers need to be above this point
case 'm':
cpx += p.shift();
cpy += p.shift();
var dx = p.shift();
var dy = p.shift();
cpx += dx;
cpy += dy;
cmd = 'M';
// After closing the path move the current position
// to the the first point of the path (if any).
if(ca.length>2 && ca[ca.length-1].command==='z'){
for(var idx=ca.length-2;idx>=0;idx--){
if(ca[idx].command==='M'){
cpx=ca[idx].points[0]+dx;
cpy=ca[idx].points[1]+dy;
break;
}
}
}
points.push(cpx, cpy);
c = 'l';
// subsequent points are treated as relative lineTo