Add optional joining behavior to PathItem#closePath() again and use it in #setPathData().

This commit is contained in:
Jürg Lehni 2014-03-31 19:33:38 +02:00
parent 0dca10d192
commit 4108e9487b
3 changed files with 9 additions and 5 deletions

View file

@ -297,8 +297,8 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
this.moveTo(last ? point.add(last._point) : point);
},
closePath: function() {
getCurrentPath(this, true).closePath();
closePath: function(join) {
getCurrentPath(this, true).closePath(join);
}
};

View file

@ -2515,8 +2515,10 @@ var Path = PathItem.extend(/** @lends Path# */{
}
},
closePath: function() {
closePath: function(join) {
this.setClosed(true);
if (join)
this.join();
}
};
}, { // A dedicated scope for the tricky bounds calculations

View file

@ -227,7 +227,7 @@ var PathItem = Item.extend(/** @lends PathItem# */{
case 'l':
var move = lower === 'm';
if (move && previous && previous !== 'z')
this.closePath();
this.closePath(true);
for (var j = 0; j < length; j += 2)
this[j === 0 && move ? 'moveTo' : 'lineTo'](
current = getPoint(j));
@ -290,7 +290,7 @@ var PathItem = Item.extend(/** @lends PathItem# */{
}
break;
case 'z':
this.closePath();
this.closePath(true);
break;
}
previous = lower;
@ -563,6 +563,8 @@ var PathItem = Item.extend(/** @lends PathItem# */{
*
* @name PathItem#closePath
* @function
* @param {Boolean} join controls whether the method should attempt to merge
* the first segment with the last if they lie in the same location.
* @see Path#closed
*/