UNPKG

arcade-physics

Version:
44 lines 1.78 kB
"use strict"; /** * @author Florian Vazelle * @author Geoffrey Glaive * @copyright 2020 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const GetLineToCircle_1 = __importDefault(require("./GetLineToCircle")); const CircleToRectangle_1 = __importDefault(require("./CircleToRectangle")); /** * Checks for intersection between a circle and a rectangle, * and returns the intersection points as a Point object array. * * @function Phaser.Geom.Intersects.GetCircleToRectangle * @since 3.0.0 * * @param {Phaser.Geom.Circle} circle - The circle to be checked. * @param {Phaser.Geom.Rectangle} rect - The rectangle to be checked. * @param {array} [out] - An optional array in which to store the points of intersection. * * @return {array} An array with the points of intersection if objects intersect, otherwise an empty array. */ const GetCircleToRectangle = (circle, rect, out) => { if (out === undefined) { out = []; } if ((0, CircleToRectangle_1.default)(circle, rect)) { const lineA = rect.getLineA(); const lineB = rect.getLineB(); const lineC = rect.getLineC(); const lineD = rect.getLineD(); (0, GetLineToCircle_1.default)(lineA, circle, out); (0, GetLineToCircle_1.default)(lineB, circle, out); (0, GetLineToCircle_1.default)(lineC, circle, out); (0, GetLineToCircle_1.default)(lineD, circle, out); } return out; }; exports.default = GetCircleToRectangle; //# sourceMappingURL=GetCircleToRectangle.js.map