mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat(Animation): Add In&Out easings
This commit is contained in:
parent
71c8f453d0
commit
0a35700ee3
10 changed files with 230 additions and 3 deletions
27
Dalamud/Interface/Animation/EasingFunctions/InCirc.cs
Normal file
27
Dalamud/Interface/Animation/EasingFunctions/InCirc.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Dalamud/Interface/Animation/EasingFunctions/InCubic.cs
Normal file
27
Dalamud/Interface/Animation/EasingFunctions/InCubic.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Dalamud/Interface/Animation/EasingFunctions/InElastic.cs
Normal file
33
Dalamud/Interface/Animation/EasingFunctions/InElastic.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Interface.Animation.EasingFunctions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
27
Dalamud/Interface/Animation/EasingFunctions/InSine.cs
Normal file
27
Dalamud/Interface/Animation/EasingFunctions/InSine.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Dalamud/Interface/Animation/EasingFunctions/OutCirc.cs
Normal file
27
Dalamud/Interface/Animation/EasingFunctions/OutCirc.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Dalamud/Interface/Animation/EasingFunctions/OutElastic.cs
Normal file
33
Dalamud/Interface/Animation/EasingFunctions/OutElastic.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Dalamud/Interface/Animation/EasingFunctions/OutQuint.cs
Normal file
27
Dalamud/Interface/Animation/EasingFunctions/OutQuint.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Dalamud/Interface/Animation/EasingFunctions/OutSine.cs
Normal file
27
Dalamud/Interface/Animation/EasingFunctions/OutSine.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue