/
Inflate.js
36 lines (30 loc) · 1.11 KB
/
Inflate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var CenterOn = require('./CenterOn');
/**
* Increases the size of a Rectangle by a specified amount.
*
* The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument.
*
* @function Phaser.Geom.Rectangle.Inflate
* @since 3.0.0
*
* @generic {Phaser.Geom.Rectangle} O - [rect,$return]
*
* @param {Phaser.Geom.Rectangle} rect - The Rectangle to inflate.
* @param {number} x - How many pixels the left and the right side should be moved by horizontally.
* @param {number} y - How many pixels the top and the bottom side should be moved by vertically.
*
* @return {Phaser.Geom.Rectangle} The inflated Rectangle.
*/
var Inflate = function (rect, x, y)
{
var cx = rect.centerX;
var cy = rect.centerY;
rect.setSize(rect.width + (x * 2), rect.height + (y * 2));
return CenterOn(rect, cx, cy);
};
module.exports = Inflate;