//============================================================================= // Sphinx-MathEasing.js //============================================================================= /*: * @plugindesc Fonctions d'accélération * @author Sphinx * * @help * //========================================================================== * // Plugin : Sphinx-MathEasing * // Date : 29 décembre 2019 * // Auteur : Sphinx * //========================================================================== * Fonctions d'accélérations. Retourne la valeur de la propriété à un instant T * d'une animation * * Ces équations de ont été trouvées sur le site http://www.gizma.com/easing/ * et ont été assemblées dans un plugin par moi-même. * Vous pouvez bien entendu rajouter vos propres équations en enrichissant * l'objet Math. * * Chacune de ces fonctions prend 4 arguments en paramètres, dans cet ordre : * - t : temps écoulé (depuis le début de l'animation) * - b : valeur au début de l'animation * - c : décallage à la fin de l'animation par rapport à la valeur au début * - d : durée totale de l'animation * * Liste des fonctions d'accélération disponibles : * - Math.easing.linearTween * - Math.easing.easeInQuad * - Math.easing.easeOutQuad * - Math.easing.easeInOutQuad * - Math.easing.easeInCubic * - Math.easing.easeOutCubic * - Math.easing.easeInOutCubic * - Math.easing.easeInQuart * - Math.easing.easeOutQuart * - Math.easing.easeInOutQuart * - Math.easing.easeInQuint * - Math.easing.easeOutQuint * - Math.easing.easeInOutQuint * - Math.easing.easeInSine * - Math.easing.easeOutSine * - Math.easing.easeInOutSine * - Math.easing.easeInExpo * - Math.easing.easeOutExpo * - Math.easing.easeInOutExpo * - Math.easing.easeInCirc * - Math.easing.easeOutCirc * - Math.easing.easeInOutCirc * * Ce plugin n'a pas beaucoup d'effet seul, il a vocation à être utilisé dans * d'autres plugins utilisant des animations, par exemple. * * Dépendances : * Aucune */ Math.easing = {}; Math.easing.linearTween = function (t, b, c, d) { return c*t/d + b; }; Math.easing.easeInQuad = function (t, b, c, d) { t /= d; return c*t*t + b; }; Math.easing.easeOutQuad = function (t, b, c, d) { t /= d; return -c * t*(t-2) + b; }; Math.easing.easeInOutQuad = function (t, b, c, d) { t /= d/2; if (t < 1) return c/2*t*t + b; t--; return -c/2 * (t*(t-2) - 1) + b; }; Math.easing.easeInCubic = function (t, b, c, d) { t /= d; return c*t*t*t + b; }; Math.easing.easeOutCubic = function (t, b, c, d) { t /= d; t--; return c*(t*t*t + 1) + b; }; Math.easing.easeInOutCubic = function (t, b, c, d) { t /= d/2; if (t < 1) return c/2*t*t*t + b; t -= 2; return c/2*(t*t*t + 2) + b; }; Math.easing.easeInQuart = function (t, b, c, d) { t /= d; return c*t*t*t*t + b; }; Math.easing.easeOutQuart = function (t, b, c, d) { t /= d; t--; return -c * (t*t*t*t - 1) + b; }; Math.easing.easeInOutQuart = function (t, b, c, d) { t /= d/2; if (t < 1) return c/2*t*t*t*t + b; t -= 2; return -c/2 * (t*t*t*t - 2) + b; }; Math.easing.easeInQuint = function (t, b, c, d) { t /= d; return c*t*t*t*t*t + b; }; Math.easing.easeOutQuint = function (t, b, c, d) { t /= d; t--; return c*(t*t*t*t*t + 1) + b; }; Math.easing.easeInOutQuint = function (t, b, c, d) { t /= d/2; if (t < 1) return c/2*t*t*t*t*t + b; t -= 2; return c/2*(t*t*t*t*t + 2) + b; }; Math.easing.easeInSine = function (t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b; }; Math.easing.easeOutSine = function (t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b; }; Math.easing.easeInOutSine = function (t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; }; Math.easing.easeInExpo = function (t, b, c, d) { return c * Math.pow( 2, 10 * (t/d - 1) ) + b; }; Math.easing.easeOutExpo = function (t, b, c, d) { return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b; }; Math.easing.easeInOutExpo = function (t, b, c, d) { t /= d/2; if (t < 1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b; t--; return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b; }; Math.easing.easeInCirc = function (t, b, c, d) { t /= d; return -c * (Math.sqrt(1 - t*t) - 1) + b; }; Math.easing.easeOutCirc = function (t, b, c, d) { t /= d; t--; return c * Math.sqrt(1 - t*t) + b; }; Math.easing.easeInOutCirc = function (t, b, c, d) { t /= d/2; if (t < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; t -= 2; return c/2 * (Math.sqrt(1 - t*t) + 1) + b; };