phaser
Version:
A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers from the team at Phaser Studio Inc.
33 lines (30 loc) • 861 B
JavaScript
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2026 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Quadratic ease-in/out. Applies a quadratic curve that accelerates in the first half
* of the range and decelerates in the second half, producing a smooth S-curve transition.
* Useful for animations that need to start gently, move briskly through the middle, and
* settle smoothly at the end.
*
* @function Phaser.Math.Easing.Quadratic.InOut
* @since 3.0.0
*
* @param {number} v - The value to be eased, in the range [0, 1].
*
* @return {number} The eased value, in the range [0, 1].
*/
var InOut = function (v)
{
if ((v *= 2) < 1)
{
return 0.5 * v * v;
}
else
{
return -0.5 * (--v * (v - 2) - 1);
}
};
module.exports = InOut;