{"version":3,"file":"rectangleExtras.mjs","sources":["../src/rectangleExtras.ts"],"sourcesContent":["import { Rectangle } from 'pixijs/core';\n\n/**\n * Determines whether the `other` Rectangle is contained within `this` Rectangle object.\n * Rectangles that occupy the same space are considered to be containing each other.\n * Rectangles without area (width or height equal to zero) can't contain anything,\n * not even other arealess rectangles.\n *\n * _Note: Only available with **pixijs/math/extras**._\n * @method containsRect\n * @memberof PIXI.Rectangle#\n * @param {Rectangle} other - The Rectangle to fit inside `this`.\n * @returns {boolean} A value of `true` if `this` Rectangle contains `other`; otherwise `false`.\n */\nRectangle.prototype.containsRect = function containsRect(other: Rectangle): boolean\n{\n    if (other.width <= 0 || other.height <= 0)\n    {\n        return other.x > this.x && other.y > this.y && other.right < this.right && other.bottom < this.bottom;\n    }\n\n    return other.x >= this.x && other.y >= this.y && other.right <= this.right && other.bottom <= this.bottom;\n};\n\n/**\n * Accepts `other` Rectangle and returns true if the given Rectangle is equal to `this` Rectangle.\n *\n * _Note: Only available with **pixijs/math/extras**._\n * @method equals\n * @memberof PIXI.Rectangle#\n * @param {Rectangle} other - The Rectangle to compare with `this`\n * @returns {boolean} Returns true if all `x`, `y`, `width`, and `height` are equal.\n */\nRectangle.prototype.equals = function equals(other: Rectangle): boolean\n{\n    if (other === this)\n    {\n        return true;\n    }\n\n    return other && this.x === other.x && this.y === other.y && this.width === other.width && this.height === other.height;\n};\n\n/**\n * If the area of the intersection between the Rectangles `other` and `this` is not zero,\n * returns the area of intersection as a Rectangle object. Otherwise, return an empty Rectangle\n * with its properties set to zero.\n * Rectangles without area (width or height equal to zero) can't intersect or be intersected\n * and will always return an empty rectangle with its properties set to zero.\n *\n * _Note: Only available with **pixijs/math/extras**._\n * @method intersection\n * @memberof PIXI.Rectangle#\n * @param {Rectangle} other - The Rectangle to intersect with `this`.\n * @param {Rectangle} [outRect] - A Rectangle object in which to store the value,\n * optional (otherwise will create a new Rectangle).\n * @returns {Rectangle} The intersection of `this` and `other`.\n */\nRectangle.prototype.intersection = function intersection<T extends Rectangle>(other: Rectangle, outRect?: T): T\n{\n    if (!outRect)\n    {\n        (outRect as any) = new Rectangle();\n    }\n\n    const x0 = this.x < other.x ? other.x : this.x;\n    const x1 = this.right > other.right ? other.right : this.right;\n\n    if (x1 <= x0)\n    {\n        outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n        return outRect;\n    }\n\n    const y0 = this.y < other.y ? other.y : this.y;\n    const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;\n\n    if (y1 <= y0)\n    {\n        outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n        return outRect;\n    }\n\n    outRect.x = x0;\n    outRect.y = y0;\n    outRect.width = x1 - x0;\n    outRect.height = y1 - y0;\n\n    return outRect;\n};\n\n/**\n * Adds `this` and `other` Rectangles together to create a new Rectangle object filling\n * the horizontal and vertical space between the two rectangles.\n *\n * _Note: Only available with **pixijs/math/extras**._\n * @method union\n * @memberof PIXI.Rectangle#\n * @param {Rectangle} other - The Rectangle to unite with `this`.\n * @param {Rectangle} [outRect] - A Rectangle object in which to store the value,\n * optional (otherwise will create a new Rectangle).\n * @returns {Rectangle} The union of `this` and `other`.\n */\nRectangle.prototype.union = function union<T extends Rectangle>(other: Rectangle, outRect?: T): T\n{\n    if (!outRect)\n    {\n        (outRect as any) = new Rectangle();\n    }\n\n    const x1 = Math.min(this.x, other.x);\n    const x2 = Math.max(this.x + this.width, other.x + other.width);\n    const y1 = Math.min(this.y, other.y);\n    const y2 = Math.max(this.y + this.height, other.y + other.height);\n\n    outRect.x = x1;\n    outRect.y = y1;\n    outRect.width = x2 - x1;\n    outRect.height = y2 - y1;\n\n    return outRect;\n};\n"],"names":[],"mappings":";;AAcA,SAAU,CAAA,SAAA,CAAU,YAAe,GAAA,SAAA,YAAA,CAAsB,KACzD,EAAA;AACI,EAAA,IAAI,KAAM,CAAA,KAAA,IAAS,CAAK,IAAA,KAAA,CAAM,UAAU,CACxC,EAAA;AACI,IAAA,OAAO,KAAM,CAAA,CAAA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