diff --git a/Dalamud/Interface/Animation/EasingFunctions/InOutElastic.cs b/Dalamud/Interface/Animation/EasingFunctions/InOutElastic.cs new file mode 100644 index 000000000..1a99f2836 --- /dev/null +++ b/Dalamud/Interface/Animation/EasingFunctions/InOutElastic.cs @@ -0,0 +1,35 @@ +using System; + +namespace Dalamud.Interface.Animation.EasingFunctions +{ + /// + /// Class providing an "InOutCirc" easing animation. + /// + public class InOutElastic : Easing + { + private static readonly double Constant = (2 * Math.PI) / 4.5; + + /// + /// Initializes a new instance of the class. + /// + /// The duration of the animation. + public InOutElastic(TimeSpan duration) + : base(duration) + { + // ignored + } + + /// + public override void Update() + { + var p = this.Progress; + this.Value = p == 0 + ? 0 + : p == 1 + ? 1 + : p < 0.5 + ? -(Math.Pow(2, (20 * p) - 10) * Math.Sin(((20 * p) - 11.125) * Constant)) / 2 + : (Math.Pow(2, (-20 * p) + 10) * Math.Sin(((20 * p) - 11.125) * Constant) / 2) + 1; + } + } +}