mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
Move copyright to the top of files.
This commit is contained in:
@@ -26,40 +26,40 @@ constexpr float kPi2 = kPi / 2.f;
|
||||
// To Public License, Version 2, as published by Sam Hocevar. See
|
||||
// http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
// Modeled after the line y = x
|
||||
/// @brief Modeled after the line y = x
|
||||
float Linear(float p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
// Modeled after the parabola y = x^2
|
||||
/// @brief Modeled after the parabola y = x^2
|
||||
float QuadraticIn(float p) {
|
||||
return p * p;
|
||||
}
|
||||
|
||||
// Modeled after the parabola y = -x^2 + 2x
|
||||
// @brief Modeled after the parabola y = -x^2 + 2x
|
||||
float QuadraticOut(float p) {
|
||||
return -(p * (p - 2.f));
|
||||
}
|
||||
|
||||
// Modeled after the piecewise quadratic
|
||||
// @brief Modeled after the piecewise quadratic
|
||||
// y = (1/2)((2x)^2) ; [0, 0.5)
|
||||
// y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
|
||||
float QuadraticInOut(float p) {
|
||||
return p < 0.5f ? 2.f * p * p : (-2.f * p * p) + (4.f * p) - 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the cubic y = x^3
|
||||
// @brief Modeled after the cubic y = x^3
|
||||
float CubicIn(float p) {
|
||||
return p * p * p;
|
||||
}
|
||||
|
||||
// Modeled after the cubic y = (x - 1)^3 + 1
|
||||
// @brief Modeled after the cubic y = (x - 1)^3 + 1
|
||||
float CubicOut(float p) {
|
||||
const float f = (p - 1.f);
|
||||
return f * f * f + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the piecewise cubic
|
||||
// @brief Modeled after the piecewise cubic
|
||||
// y = (1/2)((2x)^3) ; [0, 0.5)
|
||||
// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
|
||||
float CubicInOut(float p) {
|
||||
@@ -70,18 +70,18 @@ float CubicInOut(float p) {
|
||||
return 0.5f * f * f * f + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the quartic x^4
|
||||
// @brief Modeled after the quartic x^4
|
||||
float QuarticIn(float p) {
|
||||
return p * p * p * p;
|
||||
}
|
||||
|
||||
// Modeled after the quartic y = 1 - (x - 1)^4
|
||||
// @brief Modeled after the quartic y = 1 - (x - 1)^4
|
||||
float QuarticOut(float p) {
|
||||
const float f = (p - 1.f);
|
||||
return f * f * f * (1.f - p) + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the piecewise quartic
|
||||
// @brief Modeled after the piecewise quartic
|
||||
// y = (1/2)((2x)^4) ; [0, 0.5)
|
||||
// y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
|
||||
float QuarticInOut(float p) {
|
||||
@@ -92,18 +92,18 @@ float QuarticInOut(float p) {
|
||||
return -8.f * f * f * f * f + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the quintic y = x^5
|
||||
// @brief Modeled after the quintic y = x^5
|
||||
float QuinticIn(float p) {
|
||||
return p * p * p * p * p;
|
||||
}
|
||||
|
||||
// Modeled after the quintic y = (x - 1)^5 + 1
|
||||
// @brief Modeled after the quintic y = (x - 1)^5 + 1
|
||||
float QuinticOut(float p) {
|
||||
const float f = (p - 1.f);
|
||||
return f * f * f * f * f + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the piecewise quintic
|
||||
// @brief Modeled after the piecewise quintic
|
||||
// y = (1/2)((2x)^5) ; [0, 0.5)
|
||||
// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
|
||||
float QuinticInOut(float p) {
|
||||
@@ -114,32 +114,32 @@ float QuinticInOut(float p) {
|
||||
return 0.5f * f * f * f * f * f + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after quarter-cycle of sine wave
|
||||
// @brief Modeled after quarter-cycle of sine wave
|
||||
float SineIn(float p) {
|
||||
return std::sin((p - 1.f) * kPi2) + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after quarter-cycle of sine wave (different phase)
|
||||
// @brief Modeled after quarter-cycle of sine wave (different phase)
|
||||
float SineOut(float p) {
|
||||
return std::sin(p * kPi2);
|
||||
}
|
||||
|
||||
// Modeled after half sine wave
|
||||
// @brief Modeled after half sine wave
|
||||
float SineInOut(float p) {
|
||||
return 0.5f * (1.f - std::cos(p * kPi));
|
||||
}
|
||||
|
||||
// Modeled after shifted quadrant IV of unit circle
|
||||
// @brief Modeled after shifted quadrant IV of unit circle
|
||||
float CircularIn(float p) {
|
||||
return 1.f - std::sqrt(1.f - (p * p));
|
||||
}
|
||||
|
||||
// Modeled after shifted quadrant II of unit circle
|
||||
// @brief Modeled after shifted quadrant II of unit circle
|
||||
float CircularOut(float p) {
|
||||
return std::sqrt((2.f - p) * p);
|
||||
}
|
||||
|
||||
// Modeled after the piecewise circular function
|
||||
// @brief Modeled after the piecewise circular function
|
||||
// y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5)
|
||||
// y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
|
||||
float CircularInOut(float p) {
|
||||
@@ -149,17 +149,17 @@ float CircularInOut(float p) {
|
||||
return 0.5f * (std::sqrt(-((2.f * p) - 3.f) * ((2.f * p) - 1.f)) + 1.f);
|
||||
}
|
||||
|
||||
// Modeled after the exponential function y = 2^(10(x - 1))
|
||||
// @brief Modeled after the exponential function y = 2^(10(x - 1))
|
||||
float ExponentialIn(float p) {
|
||||
return (p == 0.f) ? p : std::pow(2.f, 10.f * (p - 1.f));
|
||||
}
|
||||
|
||||
// Modeled after the exponential function y = -2^(-10x) + 1
|
||||
// @brief Modeled after the exponential function y = -2^(-10x) + 1
|
||||
float ExponentialOut(float p) {
|
||||
return (p == 1.f) ? p : 1.f - std::pow(2.f, -10.f * p);
|
||||
}
|
||||
|
||||
// Modeled after the piecewise exponential
|
||||
// @brief Modeled after the piecewise exponential
|
||||
// y = (1/2)2^(10(2x - 1)) ; [0,0.5)
|
||||
// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
|
||||
float ExponentialInOut(float p) {
|
||||
@@ -173,18 +173,20 @@ float ExponentialInOut(float p) {
|
||||
return -0.5f * std::pow(2.f, (-20.f * p) + 10.f) + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1))
|
||||
// @brief Modeled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x -
|
||||
// 1))
|
||||
float ElasticIn(float p) {
|
||||
return std::sin(13.f * kPi2 * p) * std::pow(2.f, 10.f * (p - 1.f));
|
||||
}
|
||||
|
||||
// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) +
|
||||
// @brief Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2,
|
||||
// -10x) +
|
||||
// 1
|
||||
float ElasticOut(float p) {
|
||||
return std::sin(-13.f * kPi2 * (p + 1.f)) * std::pow(2.f, -10.f * p) + 1.f;
|
||||
}
|
||||
|
||||
// Modeled after the piecewise exponentially-damped sine wave:
|
||||
// @brief Modeled after the piecewise exponentially-damped sine wave:
|
||||
// y = (1/2)*sin(13pi/2*(2*x))*pow(2, 10 * ((2*x) - 1)) ; [0,0.5)
|
||||
// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
|
||||
float ElasticInOut(float p) {
|
||||
@@ -197,18 +199,18 @@ float ElasticInOut(float p) {
|
||||
2.f);
|
||||
}
|
||||
|
||||
// Modeled after the overshooting cubic y = x^3-x*sin(x*pi)
|
||||
// @brief Modeled after the overshooting cubic y = x^3-x*sin(x*pi)
|
||||
float BackIn(float p) {
|
||||
return p * p * p - p * std::sin(p * kPi);
|
||||
}
|
||||
|
||||
// Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi))
|
||||
// @brief Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi))
|
||||
float BackOut(float p) {
|
||||
const float f = (1.f - p);
|
||||
return 1.f - (f * f * f - f * std::sin(f * kPi));
|
||||
}
|
||||
|
||||
// Modeled after the piecewise overshooting cubic function:
|
||||
// @brief Modeled after the piecewise overshooting cubic function:
|
||||
// y = (1/2)*((2x)^3-(2x)*sin(2*x*pi)) ; [0, 0.5)
|
||||
// y = (1/2)*(1-((1-x)^3-(1-x)*sin((1-x)*pi))+1) ; [0.5, 1]
|
||||
float BackInOut(float p) {
|
||||
|
Reference in New Issue
Block a user