mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Allow read() methods to receive an optional length parameter.
This commit is contained in:
parent
ecbd52cdf7
commit
3a46ac3b54
6 changed files with 12 additions and 12 deletions
|
@ -477,8 +477,8 @@ var Point = Base.extend({
|
||||||
return point;
|
return point;
|
||||||
},
|
},
|
||||||
|
|
||||||
read: function(args, index) {
|
read: function(args, index, length) {
|
||||||
var index = index || 0, length = args.length - index;
|
var index = index || 0, length = length || args.length - index;
|
||||||
if (length == 1 && args[index] instanceof Point) {
|
if (length == 1 && args[index] instanceof Point) {
|
||||||
return args[index];
|
return args[index];
|
||||||
} else if (length != 0) {
|
} else if (length != 0) {
|
||||||
|
|
|
@ -285,8 +285,8 @@ Rectangle = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
read: function(args, index) {
|
read: function(args, index, length) {
|
||||||
var index = index || 0, length = args.length - index;
|
var index = index || 0, length = length || args.length - index;
|
||||||
if (length == 1 && args[index] instanceof Rectangle) {
|
if (length == 1 && args[index] instanceof Rectangle) {
|
||||||
return args[index];
|
return args[index];
|
||||||
} else if (length != 0) {
|
} else if (length != 0) {
|
||||||
|
|
|
@ -94,8 +94,8 @@ var Size = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
read: function(args, index) {
|
read: function(args, index, length) {
|
||||||
var index = index || 0, length = args.length - index;
|
var index = index || 0, length = length || args.length - index;
|
||||||
if (length == 1 && args[index] instanceof Size) {
|
if (length == 1 && args[index] instanceof Size) {
|
||||||
return args[index];
|
return args[index];
|
||||||
} else if (length != 0) {
|
} else if (length != 0) {
|
||||||
|
|
|
@ -31,8 +31,8 @@ Color = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
read: function(args, index) {
|
read: function(args, index, length) {
|
||||||
var index = index || 0, length = args.length - index;
|
var index = index || 0, length = length || args.length - index;
|
||||||
if (length == 1 && args[index] instanceof Color) {
|
if (length == 1 && args[index] instanceof Color) {
|
||||||
return args[index];
|
return args[index];
|
||||||
} else if (length != 0 && args[0] !== null) {
|
} else if (length != 0 && args[0] !== null) {
|
||||||
|
|
|
@ -4,8 +4,8 @@ Curve = Base.extend({
|
||||||
|
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
read: function(args, index) {
|
read: function(args, index, length) {
|
||||||
var index = index || 0, length = args.length - index;
|
var index = index || 0, length = length || args.length - index;
|
||||||
if (length == 1 && args[index] instanceof Curve) {
|
if (length == 1 && args[index] instanceof Curve) {
|
||||||
return args[index];
|
return args[index];
|
||||||
} else if (length != 0) {
|
} else if (length != 0) {
|
||||||
|
|
|
@ -121,8 +121,8 @@ Segment = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
read: function(args, index) {
|
read: function(args, index, length) {
|
||||||
var index = index || 0, length = args.length - index;
|
var index = index || 0, length = length || args.length - index;
|
||||||
if (length == 1 && args[index] instanceof Segment) {
|
if (length == 1 && args[index] instanceof Segment) {
|
||||||
return args[index];
|
return args[index];
|
||||||
} else if (length != 0) {
|
} else if (length != 0) {
|
||||||
|
|
Loading…
Reference in a new issue