phaser/src/geom/ellipse/ContainsRect.js

31 lines
959 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2022-02-28 14:29:51 +00:00
* @copyright 2022 Photon Storm Ltd.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2018-02-12 16:01:20 +00:00
*/
2017-01-02 00:47:16 +00:00
var Contains = require('./Contains');
2017-10-13 13:11:54 +00:00
/**
2018-01-26 04:53:16 +00:00
* Check to see if the Ellipse contains all four points of the given Rectangle object.
2017-10-13 13:11:54 +00:00
*
* @function Phaser.Geom.Ellipse.ContainsRect
* @since 3.0.0
*
* @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check.
2018-03-20 15:01:08 +00:00
* @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not.
2017-10-13 13:11:54 +00:00
*
2018-01-26 04:53:16 +00:00
* @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false.
2017-10-13 13:11:54 +00:00
*/
2017-01-02 00:47:16 +00:00
var ContainsRect = function (ellipse, rect)
{
return (
Contains(ellipse, rect.x, rect.y) &&
Contains(ellipse, rect.right, rect.y) &&
Contains(ellipse, rect.x, rect.bottom) &&
Contains(ellipse, rect.right, rect.bottom)
);
};
module.exports = ContainsRect;