1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var Rectangle = (function () {
|
8 | function Rectangle(left, right, top, bottom) {
|
9 | if (left === void 0) { left = 0; }
|
10 | if (right === void 0) { right = 0; }
|
11 | if (top === void 0) { top = 0; }
|
12 | if (bottom === void 0) { bottom = 0; }
|
13 | this.top = top;
|
14 | this.bottom = bottom;
|
15 | this.left = left;
|
16 | this.right = right;
|
17 | }
|
18 | Object.defineProperty(Rectangle.prototype, "width", {
|
19 | |
20 |
|
21 |
|
22 | get: function () {
|
23 | return this.right - this.left;
|
24 | },
|
25 | enumerable: true,
|
26 | configurable: true
|
27 | });
|
28 | Object.defineProperty(Rectangle.prototype, "height", {
|
29 | |
30 |
|
31 |
|
32 | get: function () {
|
33 | return this.bottom - this.top;
|
34 | },
|
35 | enumerable: true,
|
36 | configurable: true
|
37 | });
|
38 | |
39 |
|
40 |
|
41 | Rectangle.prototype.equals = function (rect) {
|
42 |
|
43 |
|
44 | return (parseFloat(this.top.toFixed(4)) === parseFloat(rect.top.toFixed(4)) &&
|
45 | parseFloat(this.bottom.toFixed(4)) === parseFloat(rect.bottom.toFixed(4)) &&
|
46 | parseFloat(this.left.toFixed(4)) === parseFloat(rect.left.toFixed(4)) &&
|
47 | parseFloat(this.right.toFixed(4)) === parseFloat(rect.right.toFixed(4)));
|
48 | };
|
49 | return Rectangle;
|
50 | }());
|
51 | export { Rectangle };
|
52 |
|
\ | No newline at end of file |