mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-27 22:29:11 -04:00
Optimise read() functions to only convert if argument is not of desired type already.
This commit is contained in:
parent
d67055b09b
commit
0ac19a8e82
4 changed files with 14 additions and 4 deletions
src/basic
|
@ -88,12 +88,15 @@ var Size = Base.extend({
|
|||
|
||||
statics: {
|
||||
read: function(args) {
|
||||
if(args.length) {
|
||||
if (args.length == 1 && args[0] instanceof Size) {
|
||||
return args[0];
|
||||
} else if (args.length) {
|
||||
var size = new Size();
|
||||
size.initialize.apply(size, args);
|
||||
return size;
|
||||
}
|
||||
},
|
||||
|
||||
min: function(Size1, Size2) {
|
||||
return new Size(
|
||||
Math.min(Size1.width, Size2.width),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue