Ease center (#238)

* New Center Ease methods

* New Version
This commit is contained in:
Michael Miller
2018-12-12 17:26:34 -08:00
committed by GitHub
parent 61d917bb4e
commit de143ce482
4 changed files with 97 additions and 2 deletions
+88
View File
@@ -71,6 +71,20 @@ public:
}
}
static float QuadraticCenter(float unitValue)
{
unitValue *= 2.0f;
if (unitValue < 1.0f)
{
return (-0.5f * (unitValue * unitValue - 2.0f));
}
else
{
unitValue -= 1.0f;
return (0.5f * (unitValue * unitValue + 1.0f));
}
}
static float CubicIn(float unitValue)
{
return (unitValue * unitValue * unitValue);
@@ -96,6 +110,13 @@ public:
}
}
static float CubicCenter(float unitValue)
{
unitValue *= 2.0f;
unitValue -= 1.0f;
return (0.5f * (unitValue * unitValue * unitValue) + 1);
}
static float QuarticIn(float unitValue)
{
return (unitValue * unitValue * unitValue * unitValue);
@@ -121,6 +142,20 @@ public:
}
}
static float QuarticCenter(float unitValue)
{
unitValue *= 2.0f;
unitValue -= 1.0f;
if (unitValue < 0.0f)
{
return (-0.5f * (unitValue * unitValue * unitValue * unitValue - 1.0f));
}
else
{
return (0.5f * (unitValue * unitValue * unitValue * unitValue + 1.0f));
}
}
static float QuinticIn(float unitValue)
{
return (unitValue * unitValue * unitValue * unitValue * unitValue);
@@ -146,6 +181,13 @@ public:
}
}
static float QuinticCenter(float unitValue)
{
unitValue *= 2.0f;
unitValue -= 1.0f;
return (0.5f * (unitValue * unitValue * unitValue * unitValue * unitValue + 1.0f));
}
static float SinusoidalIn(float unitValue)
{
return (-cos(unitValue * HALF_PI) + 1.0f);
@@ -161,6 +203,19 @@ public:
return -0.5 * (cos(PI * unitValue) - 1.0f);
}
static float SinusoidalCenter(float unitValue)
{
if (unitValue < 0.5f)
{
return (0.5 * sin(PI * unitValue));
}
else
{
return (-0.5 * (cos(PI * (unitValue-0.5f)) + 1.0f));
}
}
static float ExponentialIn(float unitValue)
{
return (pow(2, 10.0f * (unitValue - 1.0f)));
@@ -185,6 +240,20 @@ public:
}
}
static float ExponentialCenter(float unitValue)
{
unitValue *= 2.0f;
if (unitValue < 1.0f)
{
return (0.5f * (-pow(2, -10.0f * unitValue) + 1.0f));
}
else
{
unitValue -= 2.0f;
return (0.5f * (pow(2, 10.0f * unitValue) + 1.0f));
}
}
static float CircularIn(float unitValue)
{
if (unitValue == 1.0f)
@@ -217,6 +286,25 @@ public:
}
}
static float CircularCenter(float unitValue)
{
unitValue *= 2.0f;
unitValue -= 1.0f;
if (unitValue == 0.0f)
{
return 1.0f;
}
else if (unitValue < 0.0f)
{
return (0.5f * sqrt(1.0f - unitValue * unitValue));
}
else
{
unitValue -= 2.0f;
return (-0.5f * (sqrt(1.0f - unitValue * unitValue) - 1.0f ) + 0.5f);
}
}
static float Gamma(float unitValue)
{
return pow(unitValue, 1.0f / 0.45f);