12constexpr float kPi = 3.14159265358979323846F;
13constexpr float kPi2 = kPi / 2.F;
40 return -(p * (p - 2));
50 return (-2 * p * p) + (4 * p) - 1;
61 const float f = (p - 1);
72 const float f = ((2 * p) - 2);
73 return 0.5F * f * f * f + 1;
84 const float f = (p - 1);
85 return f * f * f * (1 - p) + 1;
93 return 8 * p * p * p * p;
95 const float f = (p - 1);
96 return -8 * f * f * f * f + 1;
102 return p * p * p * p * p;
107 const float f = (p - 1);
108 return f * f * f * f * f + 1;
116 return 16 * p * p * p * p * p;
118 float f = ((2 * p) - 2);
119 return 0.5 * f * f * f * f * f + 1;
125 return std::sin((p - 1) * kPi2) + 1;
130 return std::sin(p * kPi2);
135 return 0.5F * (1 - std::cos(p * kPi));
140 return 1 - std::sqrt(1 - (p * p));
145 return std::sqrt((2 - p) * p);
153 return 0.5F * (1 - std::sqrt(1 - 4 * (p * p)));
155 return 0.5F * (std::sqrt(-((2 * p) - 3) * ((2 * p) - 1)) + 1);
161 return (p == 0.0) ? p : std::pow(2, 10 * (p - 1));
166 return (p == 1.0) ? p : 1 - std::pow(2, -10 * p);
173 if (p == 0.0 || p == 1.F) {
178 return 0.5 * std::pow(2, (20 * p) - 10);
180 return -0.5 * std::pow(2, (-20 * p) + 10) + 1;
186 return std::sin(13.F * kPi2 * p) * std::pow(2.F, 10.F * (p - 1));
193 return std::sin(-13.F * kPi2 * (p + 1)) * std::pow(2.F, -10.F * p) + 1;
201 return 0.5 * std::sin(13.F * kPi2 * (2 * p)) *
202 std::pow(2, 10 * ((2 * p) - 1));
204 return 0.5 * (std::sin(-13.F * kPi2 * ((2 * p - 1) + 1)) *
205 std::pow(2, -10 * (2 * p - 1)) +
212 return p * p * p - p * std::sin(p * kPi);
217 const float f = (1 - p);
218 return 1 - (f * f * f - f * std::sin(f * kPi));
226 const float f = 2 * p;
227 return 0.5F * (f * f * f - f * std::sin(f * kPi));
229 float f = (1 - (2 * p - 1));
230 return 0.5F * (1 - (f * f * f - f * std::sin(f * kPi))) + 0.5;
240 return (121 * p * p) / 16.0;
241 }
else if (p < 8 / 11.0) {
242 return (363 / 40.0 * p * p) - (99 / 10.0 * p) + 17 / 5.0;
243 }
else if (p < 9 / 10.0) {
244 return (4356 / 361.0 * p * p) - (35442 / 1805.0 * p) +
247 return (54 / 5.0 * p * p) - (513 / 25.0 * p) + 268 / 25.0;
255 return 0.5F *
BounceOut(p * 2 - 1) + 0.5F;
270 easing_function_(std::move(easing_function)),
278 if (current_ >= duration_) {
287 (to_ - from_) * easing_function_(current_ / duration_);
Animator(float *from, float to=0.f, Duration duration=std::chrono::milliseconds(250), easing::Function easing_function=easing::Linear, Duration delay=std::chrono::milliseconds(0))
void OnAnimation(Params &)
Duration duration() const
The duration this animation step represents.
float CircularInOut(float p)
float BounceInOut(float p)
float CubicInOut(float p)
float CircularOut(float p)
float ExponentialInOut(float p)
float ElasticInOut(float p)
float QuarticInOut(float p)
float QuadraticInOut(float p)
float QuarticOut(float p)
float CircularIn(float p)
float ExponentialOut(float p)
float QuadraticOut(float p)
float QuinticOut(float p)
float QuadraticIn(float p)
float ExponentialIn(float p)
float ElasticOut(float p)
std::function< float(float)> Function
float QuinticInOut(float p)
std::chrono::duration< double > Duration
void RequestAnimationFrame()