Revert "clamp value of all easings by default"

This reverts commit 1aada98393.
Breaks the API.
This commit is contained in:
goat 2024-12-30 13:59:59 +01:00
parent 0cac90b032
commit b36bdb2086
17 changed files with 35 additions and 41 deletions

View file

@ -43,15 +43,9 @@ public abstract class Easing
public bool IsInverse { get; set; }
/// <summary>
/// Gets the current value of the animation, from 0 to 1.
/// Gets or sets the current value of the animation, from 0 to 1.
/// </summary>
public double Value => Math.Clamp(this.ValueUnclamped, 0, 1);
/// <summary>
/// Gets or sets the current value of the animation, not limited to a range of 0 to 1.
/// Will return numbers outside of this range if accessed beyond animation time.
/// </summary>
public double ValueUnclamped
public double Value
{
get
{

View file

@ -19,6 +19,6 @@ public class InCirc : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = 1 - Math.Sqrt(1 - Math.Pow(p, 2));
this.Value = 1 - Math.Sqrt(1 - Math.Pow(p, 2));
}
}

View file

@ -19,6 +19,6 @@ public class InCubic : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p * p * p;
this.Value = p * p * p;
}
}

View file

@ -21,7 +21,7 @@ public class InElastic : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p == 0
this.Value = p == 0
? 0
: p == 1
? 1

View file

@ -19,7 +19,7 @@ public class InOutCirc : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p < 0.5
this.Value = p < 0.5
? (1 - Math.Sqrt(1 - Math.Pow(2 * p, 2))) / 2
: (Math.Sqrt(1 - Math.Pow((-2 * p) + 2, 2)) + 1) / 2;
}

View file

@ -19,6 +19,6 @@ public class InOutCubic : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p < 0.5 ? 4 * p * p * p : 1 - (Math.Pow((-2 * p) + 2, 3) / 2);
this.Value = p < 0.5 ? 4 * p * p * p : 1 - (Math.Pow((-2 * p) + 2, 3) / 2);
}
}

View file

@ -21,7 +21,7 @@ public class InOutElastic : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p == 0
this.Value = p == 0
? 0
: p == 1
? 1

View file

@ -19,6 +19,6 @@ public class InOutQuint : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p < 0.5 ? 16 * p * p * p * p * p : 1 - (Math.Pow((-2 * p) + 2, 5) / 2);
this.Value = p < 0.5 ? 16 * p * p * p * p * p : 1 - (Math.Pow((-2 * p) + 2, 5) / 2);
}
}

View file

@ -19,6 +19,6 @@ public class InOutSine : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = -(Math.Cos(Math.PI * p) - 1) / 2;
this.Value = -(Math.Cos(Math.PI * p) - 1) / 2;
}
}

View file

@ -19,6 +19,6 @@ public class InQuint : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p * p * p * p * p;
this.Value = p * p * p * p * p;
}
}

View file

@ -19,6 +19,6 @@ public class InSine : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = 1 - Math.Cos((p * Math.PI) / 2);
this.Value = 1 - Math.Cos((p * Math.PI) / 2);
}
}

View file

@ -19,6 +19,6 @@ public class OutCirc : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = Math.Sqrt(1 - Math.Pow(p - 1, 2));
this.Value = Math.Sqrt(1 - Math.Pow(p - 1, 2));
}
}

View file

@ -19,6 +19,6 @@ public class OutCubic : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = 1 - Math.Pow(1 - p, 3);
this.Value = 1 - Math.Pow(1 - p, 3);
}
}

View file

@ -21,7 +21,7 @@ public class OutElastic : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = p == 0
this.Value = p == 0
? 0
: p == 1
? 1

View file

@ -19,6 +19,6 @@ public class OutQuint : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = 1 - Math.Pow(1 - p, 5);
this.Value = 1 - Math.Pow(1 - p, 5);
}
}

View file

@ -19,6 +19,6 @@ public class OutSine : Easing
public override void Update()
{
var p = this.Progress;
this.ValueUnclamped = Math.Sin((p * Math.PI) / 2);
this.Value = Math.Sin((p * Math.PI) / 2);
}
}

View file

@ -252,7 +252,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
this.fadeOutEasing.Update();
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, (float)this.fadeOutEasing.Value))
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, (float)Math.Max(this.fadeOutEasing.Value, 0)))
{
var i = 0;
foreach (var entry in entries)
@ -393,7 +393,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
if (overrideAlpha)
{
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, showText ? (float)logoEasing.Value : 0f);
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, showText ? (float)Math.Min(logoEasing.Value, 1) : 0f);
}
// Drop shadow