mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-27 06:10:14 -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
|
@ -87,14 +87,17 @@ var Size = Base.extend({
|
|||
},
|
||||
|
||||
statics: {
|
||||
read: function(args) {
|
||||
if (args.length == 1 && args[0] instanceof Size) {
|
||||
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 Size) {
|
||||
return args[index];
|
||||
} else if (length != 0) {
|
||||
var size = new Size();
|
||||
size.initialize.apply(size, args);
|
||||
size.initialize.apply(size, index > 0
|
||||
? Array.prototype.slice.call(args, index) : args);
|
||||
return size;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
min: function(Size1, Size2) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue