mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-01 16:49:15 -04:00
Have the CompoundPath constructor reverse the segments of all paths passed to it except for the first one. Introduce 'keepDirection' option to allow importing of already existing CompoundPath items.
This commit is contained in:
parent
35d51085a1
commit
2bfe42da05
1 changed files with 10 additions and 2 deletions
|
@ -15,12 +15,20 @@
|
|||
*/
|
||||
|
||||
var CompoundPath = this.CompoundPath = PathItem.extend({
|
||||
initialize: function(items) {
|
||||
// PORT: port the reversing of segments and keepDirection flag
|
||||
initialize: function(items, keepDirection) {
|
||||
this.base();
|
||||
this.children = [];
|
||||
if (items) {
|
||||
for (var i = 0, l = items.length; i < l; i++)
|
||||
for (var i = 0, l = items.length; i < l; i++) {
|
||||
var item = items[i];
|
||||
// All paths except for the first one are reversed when
|
||||
// creating a compound path, so that they draw holes.
|
||||
// When keepDirection is set to true, child paths aren't reversed.
|
||||
if (!keepDirection && i != l - 1)
|
||||
item.reverse();
|
||||
this.appendTop(items[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue