feat(Animation): Add In&Out easings

This commit is contained in:
goat 2021-07-18 21:53:30 +02:00
parent 71c8f453d0
commit 0a35700ee3
No known key found for this signature in database
GPG key ID: F18F057873895461
10 changed files with 230 additions and 3 deletions

View file

@ -0,0 +1,27 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "InCirc" easing animation.
/// </summary>
public class InCirc : Easing
{
/// <summary>
/// Initializes a new instance of the <see cref="InCirc"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public InCirc(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = 1 - Math.Sqrt(1 - Math.Pow(p, 2));
}
}
}

View file

@ -0,0 +1,27 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "InCubic" easing animation.
/// </summary>
public class InCubic : Easing
{
/// <summary>
/// Initializes a new instance of the <see cref="InCubic"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public InCubic(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = p * p * p;
}
}
}

View file

@ -0,0 +1,33 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "InElastic" easing animation.
/// </summary>
public class InElastic : Easing
{
private const double Constant = (2 * Math.PI) / 3;
/// <summary>
/// Initializes a new instance of the <see cref="InElastic"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public InElastic(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = p == 0
? 0
: p == 1
? 1
: -Math.Pow(2, (10 * p) - 10) * Math.Sin(((p * 10) - 10.75) * Constant);
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using Serilog;
namespace Dalamud.Interface.Animation.EasingFunctions
{

View file

@ -7,8 +7,8 @@ namespace Dalamud.Interface.Animation.EasingFunctions
/// </summary>
public class InOutElastic : Easing
{
private static readonly double Constant = (2 * Math.PI) / 4.5;
private const double Constant = (2 * Math.PI) / 4.5;
/// <summary>
/// Initializes a new instance of the <see cref="InOutElastic"/> class.
/// </summary>

View file

@ -0,0 +1,27 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "InSine" easing animation.
/// </summary>
public class InSine : Easing
{
/// <summary>
/// Initializes a new instance of the <see cref="InSine"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public InSine(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = 1 - Math.Cos((p * Math.PI) / 2);
}
}
}

View file

@ -0,0 +1,27 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "OutCirc" easing animation.
/// </summary>
public class OutCirc : Easing
{
/// <summary>
/// Initializes a new instance of the <see cref="OutCirc"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public OutCirc(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = Math.Sqrt(1 - Math.Pow(p - 1, 2));
}
}
}

View file

@ -0,0 +1,33 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "OutElastic" easing animation.
/// </summary>
public class OutElastic : Easing
{
private const double Constant = (2 * Math.PI) / 3;
/// <summary>
/// Initializes a new instance of the <see cref="OutElastic"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public OutElastic(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = p == 0
? 0
: p == 1
? 1
: (Math.Pow(2, -10 * p) * Math.Sin(((p * 10) - 0.75) * Constant)) + 1;
}
}
}

View file

@ -0,0 +1,27 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "OutQuint" easing animation.
/// </summary>
public class OutQuint : Easing
{
/// <summary>
/// Initializes a new instance of the <see cref="OutQuint"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public OutQuint(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = 1 - Math.Pow(1 - p, 5);
}
}
}

View file

@ -0,0 +1,27 @@
using System;
namespace Dalamud.Interface.Animation.EasingFunctions
{
/// <summary>
/// Class providing an "OutSine" easing animation.
/// </summary>
public class OutSine : Easing
{
/// <summary>
/// Initializes a new instance of the <see cref="OutSine"/> class.
/// </summary>
/// <param name="duration">The duration of the animation.</param>
public OutSine(TimeSpan duration)
: base(duration)
{
// ignored
}
/// <inheritdoc/>
public override void Update()
{
var p = this.Progress;
this.Value = Math.Sin((p * Math.PI) / 2);
}
}
}