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-17 20:31:28 +00:00
|
|
|
var Clamp = require('./Clamp');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a value based on the range between `min` and `max` and the percentage given.
|
|
|
|
*
|
|
|
|
* @function Phaser.Math.FromPercent
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-06-26 22:19:14 +00:00
|
|
|
* @param {number} percent - A value between 0 and 1 representing the percentage.
|
2018-05-23 09:46:16 +00:00
|
|
|
* @param {number} min - The minimum value.
|
|
|
|
* @param {number} [max] - The maximum value.
|
2017-10-17 20:31:28 +00:00
|
|
|
*
|
2018-05-23 09:46:16 +00:00
|
|
|
* @return {number} The value that is `percent` percent between `min` and `max`.
|
2017-10-17 20:31:28 +00:00
|
|
|
*/
|
|
|
|
var FromPercent = function (percent, min, max)
|
|
|
|
{
|
|
|
|
percent = Clamp(percent, 0, 1);
|
|
|
|
|
|
|
|
return (max - min) * percent;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = FromPercent;
|