Add #set() function to Point, Rectangle and Size (Matrix has it already).

This commit is contained in:
Jürg Lehni 2011-02-28 20:14:10 +01:00
parent b03ad9b090
commit 700f4aeb6a
3 changed files with 17 additions and 0 deletions

View file

@ -33,6 +33,11 @@ var Point = Base.extend({
}
},
set: function(x, y) {
this.x = x;
this.y = y;
},
/**
* Returns a copy of the point.
* This is useful as the following code only generates a flat copy:

View file

@ -46,6 +46,13 @@ Rectangle = Base.extend({
}
},
set: function(x, y, width, height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
},
getPoint: function() {
return new Point(this.x, this.y);
},

View file

@ -26,6 +26,11 @@ var Size = Base.extend({
}
},
set: function(width, height) {
this.width = width;
this.height = height;
},
add: function() {
var size = Size.read(arguments);
return new Size(this.width + size.width, this.height + size.height);