phaser/src/math/SmoothStep.js

27 lines
604 B
JavaScript
Raw Normal View History

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-10-06 03:52:41 +00:00
/**
* [description]
*
* @function Phaser.Math.SmoothStep
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} min - [description]
* @param {number} max - [description]
*
* @return {number} [description]
*/
var SmoothStep = function (x, min, max)
{
x = Math.max(0, Math.min(1, (x - min) / (max - min)));
return x * x * (3 - 2 * x);
};
module.exports = SmoothStep;