phaser/src/utils/object/GetMinMaxValue.js

34 lines
879 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var GetValue = require('./GetValue');
var Clamp = require('../../math/Clamp');
2018-01-26 14:23:00 +00:00
/**
* [description]
*
2018-07-28 20:37:51 +00:00
* @function Phaser.Utils.Objects.GetMinMaxValue
2018-01-26 14:23:00 +00:00
* @since 3.0.0
*
2018-03-19 01:07:03 +00:00
* @param {object} source - [description]
2018-01-26 14:23:00 +00:00
* @param {string} key - [description]
* @param {number} min - [description]
* @param {number} max - [description]
* @param {number} defaultValue - [description]
*
* @return {number} [description]
*/
var GetMinMaxValue = function (source, key, min, max, defaultValue)
{
if (defaultValue === undefined) { defaultValue = min; }
var value = GetValue(source, key, defaultValue);
return Clamp(value, min, max);
};
module.exports = GetMinMaxValue;