phaser/src/math/FromPercent.js

23 lines
539 B
JavaScript
Raw Normal View History

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
*
* @param {float} percent - A value between 0 and 1 representing the percentage.
* @param {number} min - [description]
* @param {number} [max] - [description]
*
* @return {number} [description]
*/
var FromPercent = function (percent, min, max)
{
percent = Clamp(percent, 0, 1);
return (max - min) * percent;
};
module.exports = FromPercent;