arcade-physics
Version:
Use Arcade Physics without Phaser.
27 lines • 946 B
JavaScript
;
/**
* @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 });
/**
* Checks if a given point is inside a Rectangle's bounds.
*
* @function Phaser.Geom.Rectangle.Contains
* @since 3.0.0
*
* @param {Phaser.Geom.Rectangle} rect - The Rectangle to check.
* @param {number} x - The X coordinate of the point to check.
* @param {number} y - The Y coordinate of the point to check.
*
* @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`.
*/
const Contains = (rect, x, y) => {
if (rect.width <= 0 || rect.height <= 0) {
return false;
}
return rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y;
};
exports.default = Contains;
//# sourceMappingURL=Contains.js.map