arcade-physics
Version:
Use Arcade Physics without Phaser.
35 lines • 1.41 kB
JavaScript
;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const CenterOn_1 = __importDefault(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.
*/
const Inflate = (rect, x, y) => {
const cx = rect.centerX;
const cy = rect.centerY;
rect.setSize(rect.width + x * 2, rect.height + y * 2);
return (0, CenterOn_1.default)(rect, cx, cy);
};
exports.default = Inflate;
//# sourceMappingURL=Inflate.js.map