mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Add optional joining behavior to PathItem#closePath() again and use it in #setPathData().
This commit is contained in:
parent
0dca10d192
commit
4108e9487b
3 changed files with 9 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue