Skip to content

Commit f751d40

Browse files
committed
Added Math.FromPercent function
1 parent d279e77 commit f751d40

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

v3/src/math/FromPercent.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var Clamp = require('./Clamp');
2+
3+
/**
4+
* Return a value based on the range between `min` and `max` and the percentage given.
5+
*
6+
* @function Phaser.Math.FromPercent
7+
* @since 3.0.0
8+
*
9+
* @param {float} percent - A value between 0 and 1 representing the percentage.
10+
* @param {number} min - [description]
11+
* @param {number} [max] - [description]
12+
*
13+
* @return {number} [description]
14+
*/
15+
var FromPercent = function (percent, min, max)
16+
{
17+
percent = Clamp(percent, 0, 1);
18+
19+
return (max - min) * percent;
20+
};
21+
22+
module.exports = FromPercent;

0 commit comments

Comments
 (0)