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}
|
|
|
|
*/
|
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
var GetValue = require('./GetValue');
|
2017-04-11 01:48:11 +00:00
|
|
|
var Clamp = require('../../math/Clamp');
|
|
|
|
|
2018-01-26 14:23:00 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Utils.Object.GetMinMaxValue
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {[type]} source - [description]
|
|
|
|
* @param {string} key - [description]
|
|
|
|
* @param {number} min - [description]
|
|
|
|
* @param {number} max - [description]
|
|
|
|
* @param {number} defaultValue - [description]
|
|
|
|
*
|
|
|
|
* @return {number} [description]
|
|
|
|
*/
|
2017-04-11 01:48:11 +00:00
|
|
|
var GetMinMaxValue = function (source, key, min, max, defaultValue)
|
|
|
|
{
|
|
|
|
if (defaultValue === undefined) { defaultValue = min; }
|
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
var value = GetValue(source, key, defaultValue);
|
2017-04-11 01:48:11 +00:00
|
|
|
|
|
|
|
return Clamp(value, min, max);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetMinMaxValue;
|