mirror of
https://github.com/photonstorm/phaser
synced 2024-12-28 05:53:49 +00:00
23 lines
621 B
JavaScript
23 lines
621 B
JavaScript
|
// Checks if rectB is fully contained within rectA
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
return
|
||
|
(
|
||
|
(rectB.x > rectA.x && rectB.x < rectA.right) &&
|
||
|
(rectB.right > rectA.x && rectB.right < rectA.right)
|
||
|
) && (
|
||
|
(rectB.y > rectA.y && rectB.y < rectA.bottom) &&
|
||
|
(rectB.bottom > rectA.y && rectB.bottom < rectA.bottom)
|
||
|
);
|
||
|
|
||
|
};
|
||
|
|
||
|
module.exports = ContainsRect;
|