diff --git a/src/Utils/rect.js b/src/Utils/rect.js index dd201e1..233685f 100644 --- a/src/Utils/rect.js +++ b/src/Utils/rect.js @@ -9,3 +9,18 @@ function Rect (x1, y1, x2, y2) { this.x2 = x2 || 0; this.y2 = y2 || 0; } + +Rect.prototype.getCenter = function () { + return { + x: (this.x1 + this.x2) / 2, + y: (this.y1 + this.y2) / 2 + }; +}; + +Rect.prototype.getWidth = function () { + return Math.abs(this.x2 - this.x1); +}; + +Rect.prototype.getHeight = function () { + return Math.abs(this.y2 - this.y1); +}; \ No newline at end of file