phaser/src/geom/rectangle/Scale.js

34 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2020-01-15 12:07:09 +00:00
* @copyright 2020 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-10-13 13:11:54 +00:00
// Scales the width and height of this Rectangle by the given amounts.
2016-12-20 17:07:16 +00:00
/**
2018-10-19 11:32:43 +00:00
* Scales the width and height of this Rectangle by the given amounts.
2017-10-13 13:11:54 +00:00
*
* @function Phaser.Geom.Rectangle.Scale
* @since 3.0.0
*
2018-03-27 13:27:08 +00:00
* @generic {Phaser.Geom.Rectangle} O - [rect,$return]
*
2018-10-19 11:32:43 +00:00
* @param {Phaser.Geom.Rectangle} rect - The `Rectangle` object that will be scaled by the specified amount(s).
* @param {number} x - The factor by which to scale the rectangle horizontally.
* @param {number} y - The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions.
2017-10-13 13:11:54 +00:00
*
2018-10-19 11:32:43 +00:00
* @return {Phaser.Geom.Rectangle} The rectangle object with updated `width` and `height` properties as calculated from the scaling factor(s).
2017-10-13 13:11:54 +00:00
*/
2016-12-20 17:07:16 +00:00
var Scale = function (rect, x, y)
{
if (y === undefined) { y = x; }
rect.width *= x;
rect.height *= y;
return rect;
};
module.exports = Scale;