UNPKG

arcade-physics

Version:
32 lines 1.15 kB
"use strict"; /** * @author Richard Davey <rich@photonstorm.com> * @copyright 2020 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ Object.defineProperty(exports, "__esModule", { value: true }); /** * Check to see if the Circle contains the given x / y coordinates. * * @function Phaser.Geom.Circle.Contains * @since 3.0.0 * * @param {Phaser.Geom.Circle} circle - The Circle to check. * @param {number} x - The x coordinate to check within the circle. * @param {number} y - The y coordinate to check within the circle. * * @return {boolean} True if the coordinates are within the circle, otherwise false. */ const Contains = (circle, x, y) => { // Check if x/y are within the bounds first if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) { const dx = (circle.x - x) * (circle.x - x); const dy = (circle.y - y) * (circle.y - y); return dx + dy <= circle.radius * circle.radius; } else { return false; } }; exports.default = Contains; //# sourceMappingURL=Contains.js.map