2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2017-10-13 13:11:54 +00:00
|
|
|
/**
|
2018-10-19 11:32:43 +00:00
|
|
|
* Tests if one rectangle fully contains another.
|
2017-10-13 13:11:54 +00:00
|
|
|
*
|
|
|
|
* @function Phaser.Geom.Rectangle.ContainsRect
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-10-19 11:32:43 +00:00
|
|
|
* @param {Phaser.Geom.Rectangle} rectA - The first rectangle.
|
|
|
|
* @param {Phaser.Geom.Rectangle} rectB - The second rectangle.
|
2017-10-13 13:11:54 +00:00
|
|
|
*
|
2018-10-19 11:32:43 +00:00
|
|
|
* @return {boolean} True only if rectA fully contains rectB.
|
2017-10-13 13:11:54 +00:00
|
|
|
*/
|
2016-12-20 17:07:16 +00:00
|
|
|
var ContainsRect = function (rectA, rectB)
|
|
|
|
{
|
|
|
|
// Volume check (if rectB volume > rectA then rectA cannot contain it)
|
|
|
|
if ((rectB.width * rectB.height) > (rectA.width * rectA.height))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-25 12:16:47 +00:00
|
|
|
return (
|
|
|
|
(rectB.x > rectA.x && rectB.x < rectA.right) &&
|
|
|
|
(rectB.right > rectA.x && rectB.right < rectA.right) &&
|
2018-02-16 18:17:51 +00:00
|
|
|
(rectB.y > rectA.y && rectB.y < rectA.bottom) &&
|
2017-01-25 12:16:47 +00:00
|
|
|
(rectB.bottom > rectA.y && rectB.bottom < rectA.bottom)
|
|
|
|
);
|
2016-12-20 17:07:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = ContainsRect;
|