UNPKG

arcade-physics

Version:
35 lines 1.22 kB
"use strict"; /** * @author Richard Davey <rich@photonstorm.com> * @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 Length_1 = __importDefault(require("../line/Length")); const Line_1 = __importDefault(require("../line/Line")); /** * Returns the perimeter of the given Polygon. * * @function Phaser.Geom.Polygon.Perimeter * @since 3.12.0 * * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the perimeter of. * * @return {number} The perimeter of the Polygon. */ const Perimeter = polygon => { const points = polygon.points; let perimeter = 0; for (let i = 0; i < points.length; i++) { const pointA = points[i]; const pointB = points[(i + 1) % points.length]; const line = new Line_1.default(pointA.x, pointA.y, pointB.x, pointB.y); perimeter += (0, Length_1.default)(line); } return perimeter; }; exports.default = Perimeter; //# sourceMappingURL=Perimeter.js.map