UNPKG

phaser

Version:

A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.

57 lines (51 loc) 1.32 kB
/** * @author Richard Davey <rich@photonstorm.com> * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * [description] * * @function Phaser.Math.Easing.Elastic.InOut * @since 3.0.0 * * @param {number} v - [description] * @param {float} [amplitude=0.1] - [description] * @param {float} [period=0.1] - [description] * * @return {number} [description] */ var InOut = function (v, amplitude, period) { if (amplitude === undefined) { amplitude = 0.1; } if (period === undefined) { period = 0.1; } if (v === 0) { return 0; } else if (v === 1) { return 1; } else { var s = period / 4; if (amplitude < 1) { amplitude = 1; } else { s = period * Math.asin(1 / amplitude) / (2 * Math.PI); } if ((v *= 2) < 1) { return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); } else { return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; } } }; module.exports = InOut;