OutInQuad
parent
7ab340380e
commit
8fd678bbb2
|
@ -124,5 +124,39 @@ namespace MoonTools.Core.Easing
|
|||
return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
|
||||
}
|
||||
}
|
||||
|
||||
// OUT IN QUAD
|
||||
|
||||
public static float OutInQuad(float t) => NormalizedTime(OutInQuad, t);
|
||||
public static float OutInQuad(float time, float start, float end) => TimeRange(OutInQuad, time, start, end);
|
||||
|
||||
public static float OutInQuad(float t, float b, float c, float d)
|
||||
{
|
||||
CheckTime(t, d);
|
||||
if (t < d / 2)
|
||||
{
|
||||
return OutQuad(t * 2, b, c / 2, d);
|
||||
}
|
||||
else
|
||||
{
|
||||
return InQuad((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
}
|
||||
|
||||
public static double OutInQuad(double t) => NormalizedTime(OutInQuad, t);
|
||||
public static double OutInQuad(double time, double start, double end) => TimeRange(OutInQuad, time, start, end);
|
||||
|
||||
public static double OutInQuad(double t, double b, double c, double d)
|
||||
{
|
||||
CheckTime(t, d);
|
||||
if (t < d / 2)
|
||||
{
|
||||
return OutQuad(t * 2, b, c / 2, d);
|
||||
}
|
||||
else
|
||||
{
|
||||
return InQuad((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,5 +123,31 @@ namespace Test
|
|||
Easing.InOutQuad(4.0, 2, 6).Should().Be(4);
|
||||
Easing.InOutQuad(5.0, 2, 6).Should().Be(5.5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OutInQuad()
|
||||
{
|
||||
Easing.OutInQuad(0.25f).Should().Be(0.375f);
|
||||
Easing.OutInQuad(0.5f).Should().Be(0.5f);
|
||||
Easing.OutInQuad(0.75f).Should().Be(0.625f);
|
||||
|
||||
Action invalidTime = () => Easing.OutInQuad(1.5f);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
|
||||
Easing.OutInQuad(0.25).Should().Be(0.375);
|
||||
Easing.OutInQuad(0.5).Should().Be(0.5);
|
||||
Easing.OutInQuad(0.75).Should().Be(0.625);
|
||||
|
||||
Easing.OutInQuad(3, 2, 6).Should().Be(3.5f);
|
||||
Easing.OutInQuad(4, 2, 6).Should().Be(4f);
|
||||
Easing.OutInQuad(5, 2, 6).Should().Be(4.5f);
|
||||
|
||||
invalidTime = () => Easing.OutInQuad(7, 2, 6);
|
||||
invalidTime.Should().Throw<ArgumentException>();
|
||||
|
||||
Easing.OutInQuad(3.0, 2, 6).Should().Be(3.5);
|
||||
Easing.OutInQuad(4.0, 2, 6).Should().Be(4);
|
||||
Easing.OutInQuad(5.0, 2, 6).Should().Be(4.5);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue