feat(Animation): add InOutElastic

This commit is contained in:
goat 2021-07-18 19:32:17 +02:00
parent bf1b8b06e6
commit 2857f37b00
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -0,0 +1,35 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "InOutCirc" easing animation.
/// </summary>
public class InOutElastic : Easing
{
private static readonly double Constant = (2 * Math.PI) / 4.5;
/// <summary>
/// Initializes a new instance of the <see cref="InOutElastic"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public InOutElastic(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
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;
}
}
}