UNPKG

phaser

Version:

A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers from the team at Phaser Studio Inc.

50 lines (44 loc) 1.22 kB
/** * @author Richard Davey <rich@phaser.io> * @copyright 2013-2025 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Elastic ease-out. * * @function Phaser.Math.Easing.Elastic.Out * @since 3.0.0 * * @param {number} v - The value to be tweened. * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. * @param {number} [period=0.1] - Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. * * @return {number} The tweened value. */ var Out = 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); } return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); } }; module.exports = Out;