File: /home/padewitte/projets/webcomponents/myscript-js/src/common/generic/rectangle.js
'use strict';
(function (scope) {
/**
* Rectangle
*
* @class Rectangle
* @param {Object} [obj]
* @constructor
*/
function Rectangle(obj) {
if (obj) {
this.x = obj.x;
this.y = obj.y;
this.width = obj.width;
this.height = obj.height;
}
}
/**
* Get top-left x
*
* @method getX
* @returns {Number}
*/
Rectangle.prototype.getX = function () {
return this.x;
};
/**
* Set top-left x
*
* @method setX
* @param {Number} x
*/
Rectangle.prototype.setX = function (x) {
this.x = x;
};
/**
* Get top-left y
*
* @method getY
* @returns {Number}
*/
Rectangle.prototype.getY = function () {
return this.y;
};
/**
* Set top-left y
*
* @method setY
* @param {Number} y
*/
Rectangle.prototype.setY = function (y) {
this.y = y;
};
/**
* Get top-left point
*
* @method getTopLeftPoint
* @returns {Point}
*/
Rectangle.prototype.getTopLeftPoint = function () {
var point = new scope.Point();
point.setX(this.x);
point.setY(this.y);
return point;
};
/**
* Set top-left point
*
* @method setTopLeftPoint
* @param {Point} topLeftPoint
*/
Rectangle.prototype.setTopLeftPoint = function (topLeftPoint) {
this.x = topLeftPoint.getX();
this.y = topLeftPoint.getY();
};
/**
* Get width
*
* @method getWidth
* @returns {Number}
*/
Rectangle.prototype.getWidth = function () {
return this.width;
};
/**
* Set width
*
* @method setWidth
* @param {Number} width
*/
Rectangle.prototype.setWidth = function (width) {
this.width = width;
};
/**
* Get height
*
* @method getHeight
* @returns {Number}
*/
Rectangle.prototype.getHeight = function () {
return this.height;
};
/**
* Set height
*
* @method setHeight
* @param {Number} height
*/
Rectangle.prototype.setHeight = function (height) {
this.height = height;
};
// Export
scope.Rectangle = Rectangle;
})(MyScript);