Clea up white spaces.

This commit is contained in:
Jürg Lehni 2011-02-13 19:21:56 +00:00
parent 420ffaa7ea
commit 20746ad3a7
3 changed files with 54 additions and 54 deletions

View file

@ -24,7 +24,7 @@ var Point = Base.extend({
this.x = this.y = 0; this.x = this.y = 0;
} }
} else { } else {
this.x = this.y = 0; this.x = this.y = 0;
} }
}, },
@ -107,7 +107,7 @@ var Point = Base.extend({
this.y *= scale; this.y *= scale;
} }
}, },
normalize: function(length) { normalize: function(length) {
if (length === null) if (length === null)
length = 1; length = 1;
@ -118,16 +118,16 @@ var Point = Base.extend({
res._angle = this._angle; res._angle = this._angle;
return res; return res;
}, },
getAngleInRadians: function() { getAngleInRadians: function() {
return Math.atan2(this.y, this.x); return Math.atan2(this.y, this.x);
}, },
getAngleInDegrees: function() { getAngleInDegrees: function() {
return Math.atan2(this.y, this.x) * 180 / Math.PI; return Math.atan2(this.y, this.x) * 180 / Math.PI;
}, },
getQuadrant: function() { getQuadrant: function() {
if (this.x >= 0) { if (this.x >= 0) {
if (this.y >= 0) { if (this.y >= 0) {
@ -143,7 +143,7 @@ var Point = Base.extend({
} }
} }
}, },
setAngle: function(angle) { setAngle: function(angle) {
angle = this._angle = angle * Math.PI / 180; angle = this._angle = angle * Math.PI / 180;
if (!this.isZero()) { if (!this.isZero()) {
@ -183,7 +183,7 @@ var Point = Base.extend({
return angle; return angle;
} }
}, },
rotate: function(angle) { rotate: function(angle) {
angle = angle * Math.PI / 180; angle = angle * Math.PI / 180;
var s = Math.sin(angle); var s = Math.sin(angle);

View file

@ -45,182 +45,182 @@ Rectangle = Base.extend({
this.x = this.y = this.width = this.height = 0; this.x = this.y = this.width = this.height = 0;
} }
}, },
getPoint: function() { getPoint: function() {
return new Point(this.x, this.y); return new Point(this.x, this.y);
}, },
setPoint: function() { setPoint: function() {
var point = Point.read(arguments); var point = Point.read(arguments);
this.x = point.x; this.x = point.x;
this.y = point.y; this.y = point.y;
}, },
getSize: function() { getSize: function() {
return new Size(this.width, this.height); return new Size(this.width, this.height);
}, },
setSize: function() { setSize: function() {
var size = Size.read(arguments); var size = Size.read(arguments);
this.width = size.width; this.width = size.width;
this.height = size.height; this.height = size.height;
}, },
getLeft: function() { getLeft: function() {
return this.x; return this.x;
}, },
setLeft: function(left) { setLeft: function(left) {
// right should not move // right should not move
this.width -= left - this.x; this.width -= left - this.x;
this.x = left; this.x = left;
}, },
getTop: function() { getTop: function() {
return this.y; return this.y;
}, },
setTop: function(top) { setTop: function(top) {
this.height -= top - this.y; this.height -= top - this.y;
this.y = top; this.y = top;
}, },
getRight: function() { getRight: function() {
return this.x + this.width; return this.x + this.width;
}, },
setRight: function(right) { setRight: function(right) {
this.width = right - this.x; this.width = right - this.x;
}, },
getBottom: function() { getBottom: function() {
return this.y + this.height; return this.y + this.height;
}, },
setBottom: function(bottom) { setBottom: function(bottom) {
this.height = bottom - this.y; this.height = bottom - this.y;
}, },
getCenterX: function() { getCenterX: function() {
return this.x + this.width * 0.5; return this.x + this.width * 0.5;
}, },
setCenterX: function(x) { setCenterX: function(x) {
this.x = x - this.width * 0.5; this.x = x - this.width * 0.5;
}, },
getCenterY: function() { getCenterY: function() {
return this.y + this.height * 0.5; return this.y + this.height * 0.5;
}, },
setCenterY: function(y) { setCenterY: function(y) {
this.y = y - this.height * 0.5; this.y = y - this.height * 0.5;
}, },
getCenter: function() { getCenter: function() {
return new Point(this.x - this.width / 2, this.y - this.height / 2); return new Point(this.x - this.width / 2, this.y - this.height / 2);
}, },
setCenter: function() { setCenter: function() {
var center = Point.read(arguments); var center = Point.read(arguments);
this.x = center.x - this.width / 2; this.x = center.x - this.width / 2;
this.y = center.y - this.height / 2; this.y = center.y - this.height / 2;
}, },
getTopLeft: function() { getTopLeft: function() {
return new Point(this.left, this.top); return new Point(this.left, this.top);
}, },
setTopLeft: function() { setTopLeft: function() {
var topLeft = Point.read(arguments); var topLeft = Point.read(arguments);
this.left = topLeft.x; this.left = topLeft.x;
this.top = topLeft.y; this.top = topLeft.y;
}, },
getTopRight: function() { getTopRight: function() {
return new Point(this.right, this.top); return new Point(this.right, this.top);
}, },
setTopRight: function() { setTopRight: function() {
var topRight = Point.read(arguments); var topRight = Point.read(arguments);
this.right = topRight.x; this.right = topRight.x;
this.top = topRight.y; this.top = topRight.y;
}, },
getBottomLeft: function() { getBottomLeft: function() {
return new Point(this.left, this.bottom); return new Point(this.left, this.bottom);
}, },
setBottomLeft: function() { setBottomLeft: function() {
var bottomLeft = Point.read(arguments); var bottomLeft = Point.read(arguments);
this.left = bottomLeft.x; this.left = bottomLeft.x;
this.bottom = bottomLeft.y; this.bottom = bottomLeft.y;
}, },
getBottomRight: function() { getBottomRight: function() {
return new Point(this.right, this.bottom); return new Point(this.right, this.bottom);
}, },
setBottomRight: function() { setBottomRight: function() {
var bottomRight = Point.read(arguments); var bottomRight = Point.read(arguments);
this.bottom = bottomRight.y; this.bottom = bottomRight.y;
this.right = bottomRight.x; this.right = bottomRight.x;
}, },
getLeftCenter: function() { getLeftCenter: function() {
return new Point(this.left, this.centerY); return new Point(this.left, this.centerY);
}, },
setLeftCenter: function() { setLeftCenter: function() {
var leftCenter = Point.read(arguments); var leftCenter = Point.read(arguments);
this.left = leftCenter.x; this.left = leftCenter.x;
this.centerY = leftCenter.y; this.centerY = leftCenter.y;
}, },
getTopCenter: function() { getTopCenter: function() {
return new Point(this.centerX, this.top); return new Point(this.centerX, this.top);
}, },
setTopCenter: function() { setTopCenter: function() {
var topCenter = Point.read(arguments); var topCenter = Point.read(arguments);
this.centerX = topCenter.x; this.centerX = topCenter.x;
this.top = topCenter.y; this.top = topCenter.y;
}, },
getRightCenter: function() { getRightCenter: function() {
return new Point(this.right, this.centerY); return new Point(this.right, this.centerY);
}, },
setRightCenter: function() { setRightCenter: function() {
var rightCenter = Point.read(arguments); var rightCenter = Point.read(arguments);
this.right = rightCenter.x; this.right = rightCenter.x;
this.centerY = rightCenter.y; this.centerY = rightCenter.y;
}, },
getBottomCenter: function() { getBottomCenter: function() {
return new Point(this.centerX, this.bottom); return new Point(this.centerX, this.bottom);
}, },
setBottomCenter: function() { setBottomCenter: function() {
var bottomCenter = Point.read(arguments); var bottomCenter = Point.read(arguments);
this.bottom = bottomCenter.y; this.bottom = bottomCenter.y;
this.centerX = bottomCenter.x; this.centerX = bottomCenter.x;
}, },
clone: function() { clone: function() {
return new Rectangle(this); return new Rectangle(this);
}, },
equals: function() { equals: function() {
var rect = Rectangle.read(arguments); var rect = Rectangle.read(arguments);
return this.x == rect.x && this.y == rect.y return this.x == rect.x && this.y == rect.y
&& this.width == rect.width && this.height == rect.height; && this.width == rect.width && this.height == rect.height;
}, },
isEmpty: function() { isEmpty: function() {
return this.width == 0 || this.height == 0; return this.width == 0 || this.height == 0;
}, },
contains: function(rect) { contains: function(rect) {
if (rect.width !== undefined) { if (rect.width !== undefined) {
return rect.x >= this.x && rect.y >= this.y return rect.x >= this.x && rect.y >= this.y
@ -233,7 +233,7 @@ Rectangle = Base.extend({
&& point.y <= this.y + this.height; && point.y <= this.y + this.height;
} }
}, },
intersects: function() { intersects: function() {
var rect = Rectangle.read(arguments); var rect = Rectangle.read(arguments);
return rect.x + rect.width > this.x return rect.x + rect.width > this.x
@ -241,7 +241,7 @@ Rectangle = Base.extend({
&& rect.x < this.x + this.width && rect.x < this.x + this.width
&& rect.y < this.y + this.height; && rect.y < this.y + this.height;
}, },
intersect: function() { intersect: function() {
var rect = Rectangle.read(arguments); var rect = Rectangle.read(arguments);
var x1 = Math.max(this.x, rect.x); var x1 = Math.max(this.x, rect.x);
@ -250,7 +250,7 @@ Rectangle = Base.extend({
var y2 = Math.min(this.y + this.height, rect.y + rect.height); var y2 = Math.min(this.y + this.height, rect.y + rect.height);
return new Rectangle(x1, y1, x2 - x1, y2 - y1); return new Rectangle(x1, y1, x2 - x1, y2 - y1);
}, },
unite: function() { unite: function() {
var rect = Rectangle.read(arguments); var rect = Rectangle.read(arguments);
var x1 = Math.min(this.x, rect.x); var x1 = Math.min(this.x, rect.x);
@ -259,7 +259,7 @@ Rectangle = Base.extend({
var y2 = Math.max(this.y + this.height, rect.y + rect.height); var y2 = Math.max(this.y + this.height, rect.y + rect.height);
return new Rectangle(x1, y1, x2 - x1, y2 - y1); return new Rectangle(x1, y1, x2 - x1, y2 - y1);
}, },
include: function() { include: function() {
var point = Point.read(arguments); var point = Point.read(arguments);
var x1 = Math.min(this.x, point.x); var x1 = Math.min(this.x, point.x);
@ -268,7 +268,7 @@ Rectangle = Base.extend({
var y2 = Math.max(this.y + this.height, point.y); var y2 = Math.max(this.y + this.height, point.y);
return new Rectangle(x1, y1, x2 - x1, y2 - y1); return new Rectangle(x1, y1, x2 - x1, y2 - y1);
}, },
toString: function() { toString: function() {
return '{ x: ' + this.x return '{ x: ' + this.x
+ ', y: ' + this.y + ', y: ' + this.y
@ -276,7 +276,7 @@ Rectangle = Base.extend({
+ ', height: ' + this.height + ', height: ' + this.height
+ ' }'; + ' }';
}, },
statics: { statics: {
read: function(args, index) { read: function(args, index) {
var index = index || 0, length = args.length - index; var index = index || 0, length = args.length - index;

View file

@ -20,10 +20,10 @@ var Size = Base.extend({
this.width = this.height = 0; this.width = this.height = 0;
} }
} else { } else {
this.width = this.height = 0; this.width = this.height = 0;
} }
}, },
add: function() { add: function() {
var size = Size.read(arguments); var size = Size.read(arguments);
return new Size(this.width + size.width, this.height + size.height); return new Size(this.width + size.width, this.height + size.height);