mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix PathItem constructor to support passing of segments both as array and arguments.
This commit is contained in:
parent
771d9d0efe
commit
a30e4057e3
1 changed files with 13 additions and 6 deletions
|
@ -38,15 +38,22 @@ PathItem = Item.extend(new function() {
|
||||||
return {
|
return {
|
||||||
beans: true,
|
beans: true,
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function(segments) {
|
||||||
this.base();
|
this.base();
|
||||||
this.closed = false;
|
this.closed = false;
|
||||||
this._segments = [];//new SegmentList(this);
|
this._segments = [];
|
||||||
this.bounds = new Rectangle();
|
this.bounds = new Rectangle();
|
||||||
for(var i = 0, l = arguments.length; i < l; i++) {
|
// Support both passing of segments as array or arguments
|
||||||
var segment = new Segment(arguments[i]);
|
// TODO: Use better isArray check, i.e. the one from
|
||||||
this.addSegment(segment);
|
// http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
|
||||||
}
|
// Or rely on Base.type()? in Bootstrap?
|
||||||
|
// If it is an array, it can also be a description of a point, so
|
||||||
|
// check its first entry for object as well
|
||||||
|
if (!segments || segments.length === undefined
|
||||||
|
|| typeof segments[0] != 'object')
|
||||||
|
segments = arguments;
|
||||||
|
for(var i = 0, l = segments.length; i < l; i++)
|
||||||
|
this.addSegment(new Segment(segments[i]));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue