From 700f4aeb6a67faabbb5ccf3a1474c53b2038fa45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 28 Feb 2011 20:14:10 +0100 Subject: [PATCH] Add #set() function to Point, Rectangle and Size (Matrix has it already). --- src/basic/Point.js | 5 +++++ src/basic/Rectangle.js | 7 +++++++ src/basic/Size.js | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/src/basic/Point.js b/src/basic/Point.js index b5f5d7cf..969eda4e 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -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: diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index c4f6a985..35444ed7 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -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); }, diff --git a/src/basic/Size.js b/src/basic/Size.js index 5ebd58bb..dae7c3fe 100644 --- a/src/basic/Size.js +++ b/src/basic/Size.js @@ -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);