mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat(Animation): add InOutElastic
This commit is contained in:
parent
bf1b8b06e6
commit
2857f37b00
1 changed files with 35 additions and 0 deletions
35
Dalamud/Interface/Animation/EasingFunctions/InOutElastic.cs
Normal file
35
Dalamud/Interface/Animation/EasingFunctions/InOutElastic.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue