arcade-physics
Version:
Use Arcade Physics without Phaser.
35 lines • 1.56 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 GetValue_1 = __importDefault(require("./GetValue"));
const Clamp_1 = __importDefault(require("../../math/Clamp"));
/**
* Retrieves and clamps a numerical value from an object.
*
* @function Phaser.Utils.Objects.GetMinMaxValue
* @since 3.0.0
*
* @param {object} source - The object to retrieve the value from.
* @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`).
* @param {number} min - The minimum value which can be returned.
* @param {number} max - The maximum value which can be returned.
* @param {number} defaultValue - The value to return if the property doesn't exist. It's also constrained to the given bounds.
*
* @return {number} The clamped value from the `source` object.
*/
const GetMinMaxValue = (source, key, min, max, defaultValue) => {
if (defaultValue === undefined) {
defaultValue = min;
}
const value = (0, GetValue_1.default)(source, key, defaultValue);
return (0, Clamp_1.default)(value, min, max);
};
exports.default = GetMinMaxValue;
//# sourceMappingURL=GetMinMaxValue.js.map