phaser4-rex-plugins
Version:
28 lines (23 loc) • 798 B
JavaScript
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
import Clamp from './Clamp.js';
/**
* Return a value based on the range between `min` and `max` and the percentage given.
*
* @function Phaser.Math.FromPercent
* @since 3.0.0
*
* @param {number} percent - A value between 0 and 1 representing the percentage.
* @param {number} min - The minimum value.
* @param {number} [max] - The maximum value.
*
* @return {number} The value that is `percent` percent between `min` and `max`.
*/
var FromPercent = function (percent, min, max) {
percent = Clamp(percent, 0, 1);
return (max - min) * percent;
};
export default FromPercent;