UNPKG

igniteui-react-core

Version:
340 lines (339 loc) 10.9 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { __extends } from "tslib"; import { Base, markType } from "./type"; /** * @hidden */ var CollisionRect = /** @class */ /*@__PURE__*/ (function (_super) { __extends(CollisionRect, _super); function CollisionRect(a) { var _rest = []; for (var _i = 1; _i < arguments.length; _i++) { _rest[_i - 1] = arguments[_i]; } var _this = _super.call(this) || this; _this.u = 0; _this.v = 0; _this.t = 0; _this.p = 0; _this.s = 0; _this.q = 0; _this.r = 0; _this.o = 0; a = (a == void 0) ? 0 : a; switch (a) { case 0: { var c = _rest[0]; _this.left = c.left; _this.top = c.top; _this.width = c.width; _this.height = c.height; } break; case 1: { var c = _rest[0]; var d = _rest[1]; var e = _rest[2]; var f = _rest[3]; _this.top = d; _this.left = c; _this.width = e; _this.height = f; } break; case 2: { var c = _rest[0]; var d = _rest[1]; var e = _rest[2]; _this.top = d; _this.left = c; _this.width = e.width; _this.height = e.height; } break; case 3: { var c = _rest[0]; var d = _rest[1]; _this.top = Math.min(c.y, d.y); _this.left = Math.min(c.x, d.x); _this.width = Math.max(Math.max(c.x, d.x) - _this.left, 0); _this.height = Math.max(Math.max(c.y, d.y) - _this.top, 0); } break; case 4: { var c = _rest[0]; var d = _rest[1]; _this.top = c.y; _this.left = c.x; _this.width = d.width; _this.height = d.height; } break; case 5: { _this.top = 0; _this.left = 0; _this.width = 0; _this.height = 0; } break; } return _this; } Object.defineProperty(CollisionRect.prototype, "x", { get: function () { return this.u; }, set: function (a) { this.u = a; this.q = this.u; this.r = this.q + this.t; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "y", { get: function () { return this.v; }, set: function (a) { this.v = a; this.s = this.v; this.o = this.s + this.p; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "width", { get: function () { return this.t; }, set: function (a) { this.t = a; this.r = this.q + this.t; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "height", { get: function () { return this.p; }, set: function (a) { this.p = a; this.o = this.s + this.p; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "top", { get: function () { return this.s; }, set: function (a) { this.s = a; this.y = this.s; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "left", { get: function () { return this.q; }, set: function (a) { this.q = a; this.x = this.q; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "right", { get: function () { return this.r; }, set: function (a) { this.r = a; this.t = this.r - this.q; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "bottom", { get: function () { return this.o; }, set: function (a) { this.o = a; this.p = this.o - this.s; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect.prototype, "isEmpty", { get: function () { return this.t < 0; }, enumerable: false, configurable: true }); Object.defineProperty(CollisionRect, "empty", { get: function () { return new CollisionRect(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); }, enumerable: false, configurable: true }); CollisionRect.prototype.equals = function (a) { if (CollisionRect.l_op_Equality(a, null)) { return false; } if (a.x == this.x && a.y == this.y && a.width == this.width && a.height == this.height) { return true; } return false; }; CollisionRect.prototype.f = function (a, b) { return a >= this.u && a - this.t <= this.u && b >= this.v && b - this.p <= this.v; }; CollisionRect.prototype.containsLocation = function (a, b) { return !this.isEmpty && this.f(a, b); }; CollisionRect.prototype.containsPoint = function (a) { return this.containsLocation(a.x, a.y); }; CollisionRect.prototype.containsRect = function (a) { return !this.isEmpty && !a.isEmpty && (this.u <= a.u && this.v <= a.v && this.u + this.t >= a.u + a.t) && this.v + this.p >= a.v + a.p; }; CollisionRect.prototype.inflate = function (a, b) { this.x -= a; this.y -= b; this.width += a * 2; this.height += b * 2; if (this.t < 0 || this.p < 0) { this.ah(); } }; CollisionRect.prototype.ah = function () { this.top = Number.POSITIVE_INFINITY; this.left = Number.POSITIVE_INFINITY; this.width = Number.NEGATIVE_INFINITY; this.height = Number.NEGATIVE_INFINITY; }; CollisionRect.prototype.intersectsWith = function (a) { if (this.isEmpty || a.isEmpty) { return false; } return a.left < this.right && this.left < a.right && a.top < this.bottom && this.top < a.bottom; }; CollisionRect.prototype.intersect = function (a) { if (!this.intersectsWith(a)) { this.ah(); } else { var b = Math.max(this.x, a.x); var c = Math.max(this.y, a.y); var d = Math.min(this.x + this.width, a.x + a.width) - b; var e = Math.min(this.y + this.height, a.y + a.height) - c; if (d < 0) { d = 0; } if (e < 0) { e = 0; } this.t = d; this.p = e; this.u = b; this.v = c; this.q = this.u; this.s = this.v; this.r = this.q + this.t; this.o = this.s + this.p; } }; CollisionRect.prototype.union = function (a) { if (this.isEmpty) { this.u = a.x; this.v = a.y; this.t = a.width; this.p = a.height; this.q = this.u; this.s = this.v; this.r = this.q + this.t; this.o = this.s + this.p; return; } if (!a.isEmpty) { var b = Math.min(this.x, a.x); var c = Math.min(this.y, a.y); var d = this.width; var e = this.height; if (a.width == Number.POSITIVE_INFINITY || this.width == Number.POSITIVE_INFINITY) { d = Number.POSITIVE_INFINITY; } else { var f = Math.max(this.right, a.right); d = f - b; } if (a.height == Number.POSITIVE_INFINITY || this.height == Number.POSITIVE_INFINITY) { e = Number.POSITIVE_INFINITY; } else { var g = Math.max(this.bottom, a.bottom); e = g - c; } this.u = b; this.v = c; this.t = d; this.p = e; this.q = this.u; this.s = this.v; this.r = this.q + this.t; this.o = this.s + this.p; } }; CollisionRect.prototype.equals1 = function (a) { if (a == null) { return _super.prototype.equals.call(this, a); } var b = a; return b.left == this.left && b.top == this.top && b.width == this.width && b.height == this.height; }; CollisionRect.prototype.getHashCode = function () { return (this.u) ^ (this.v) ^ (this.t) ^ (this.p); }; CollisionRect.prototype.copy = function () { return new CollisionRect(1, this.x, this.y, this.width, this.height); }; CollisionRect.l_op_Equality = function (a, b) { if (a == null) { return b == null; } else if (b == null) { return false; } return a.u == b.u && a.v == b.v && a.t == b.t && a.p == b.p; }; CollisionRect.l_op_Inequality = function (a, b) { if (a == null) { return b != null; } else if (b == null) { return true; } return a.u != b.u || a.v != b.v || a.t != b.t || a.p != b.p; }; CollisionRect.$t = markType(CollisionRect, 'CollisionRect'); return CollisionRect; }(Base)); export { CollisionRect };