mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-01 08:38:54 -04:00
Add optional index argument to static read() functions, so points, rectangle, sizes and segments can be read from any index in the arguments array.
This commit is contained in:
parent
08d4826441
commit
eeb7d377e6
4 changed files with 32 additions and 20 deletions
src/basic
|
@ -277,14 +277,17 @@ Rectangle = Base.extend({
|
|||
},
|
||||
|
||||
statics: {
|
||||
read: function(args) {
|
||||
if (args.length == 1 && args[0] instanceof Rectangle) {
|
||||
return args[0];
|
||||
} else if (args.length) {
|
||||
read: function(args, index) {
|
||||
var index = index || 0, length = args.length - index;
|
||||
if (length == 1 && args[index] instanceof Rectangle) {
|
||||
return args[index];
|
||||
} else if (length != 0) {
|
||||
var rect = new Rectangle();
|
||||
rect.initialize.apply(rect, args);
|
||||
rect.initialize.apply(rect, index > 0
|
||||
? Array.prototype.slice.call(args, index) : args);
|
||||
return rect;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue