mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Allow rectangles to be created from arrays too.
This commit is contained in:
parent
af66bccb64
commit
86609103fc
1 changed files with 15 additions and 8 deletions
|
@ -101,7 +101,13 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
}
|
||||
if (this._read)
|
||||
this._read = arguments._index;
|
||||
} else if (arg0) {
|
||||
} else {
|
||||
if (Array.isArray(arg0)) {
|
||||
this.x = arg0[0];
|
||||
this.y = arg0[1];
|
||||
this.width = arg0[2];
|
||||
this.height = arg0[3];
|
||||
} else {
|
||||
// new Rectangle(rect)
|
||||
// Use 0 as defaults, in case we're not reading from a Rectangle,
|
||||
// but a Point or Size instead
|
||||
|
@ -109,6 +115,7 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
this.y = arg0.y || 0;
|
||||
this.width = arg0.width || 0;
|
||||
this.height = arg0.height || 0;
|
||||
}
|
||||
if (this._read)
|
||||
this._read = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue