mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Allow passing of Paths to CompoundPath constructor as arguments, without an array object.
This commit is contained in:
parent
e9e93abb44
commit
7ba2fcad2a
1 changed files with 13 additions and 11 deletions
|
@ -18,18 +18,20 @@ var CompoundPath = this.CompoundPath = PathItem.extend({
|
||||||
initialize: function(paths) {
|
initialize: function(paths) {
|
||||||
this.base();
|
this.base();
|
||||||
this._children = [];
|
this._children = [];
|
||||||
if (paths) {
|
// Do not reassign to paths, since arguments would get modified, which
|
||||||
for (var i = 0, l = paths.length; i < l; i++) {
|
// we potentially use as array, depending on what is passed.
|
||||||
var path = paths[i];
|
var items = !paths || !Array.isArray(paths)
|
||||||
// All paths except for the top one (last one in list) are
|
|| typeof paths[0] !== 'object' ? arguments : paths;
|
||||||
// set to clockwise orientation when creating a compound path,
|
for (var i = 0, l = items.length; i < l; i++) {
|
||||||
// so that they appear as holes, but only if their orientation
|
var path = items[i];
|
||||||
// was not already specified before (= _clockwise is defined).
|
// All paths except for the top one (last one in list) are set to
|
||||||
|
// clockwise orientation when creating a compound path, so that they
|
||||||
|
// appear as holes, but only if their orientation was not already
|
||||||
|
// specified before (= _clockwise is defined).
|
||||||
if (path._clockwise === undefined)
|
if (path._clockwise === undefined)
|
||||||
path.setClockwise(i < l - 1);
|
path.setClockwise(i < l - 1);
|
||||||
this.appendTop(path);
|
this.appendTop(path);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue