12constexpr float kPi = 3.14159265358979323846f;
13constexpr float kPi2 = kPi / 2.f;
40 return -(p * (p - 2.f));
49 : (-2.f * p * p) + (4.f * p) - 1.f;
59 const float f = (p - 1.f);
60 return f * f * f + 1.f;
68 return 4.f * p * p * p;
70 const float f = ((2.f * p) - 2.f);
71 return 0.5f * f * f * f + 1.f;
81 const float f = (p - 1.f);
82 return f * f * f * (1.f - p) + 1.f;
90 return 8.f * p * p * p * p;
92 const float f = (p - 1.f);
93 return -8.f * f * f * f * f + 1.f;
98 return p * p * p * p * p;
103 const float f = (p - 1.f);
104 return f * f * f * f * f + 1.f;
112 return 16.f * p * p * p * p * p;
114 float f = ((2.f * p) - 2.f);
115 return 0.5f * f * f * f * f * f + 1.f;
120 return std::sin((p - 1.f) * kPi2) + 1.f;
125 return std::sin(p * kPi2);
130 return 0.5f * (1.f - std::cos(p * kPi));
135 return 1.f - std::sqrt(1.f - (p * p));
140 return std::sqrt((2.f - p) * p);
148 return 0.5f * (1.f - std::sqrt(1.f - 4.f * (p * p)));
151 return 0.5f * (std::sqrt(-((2.f * p) - 3.f) * ((2.f * p) - 1.f)) + 1.f);
156 return (p == 0.f) ? p : std::pow(2.f, 10.f * (p - 1.f));
161 return (p == 1.f) ? p : 1.f - std::pow(2.f, -10.f * p);
168 if (p == 0.f || p == 1.f) {
173 return 0.5f * std::pow(2.f, (20.f * p) - 10.f);
175 return -0.5f * std::pow(2.f, (-20.f * p) + 10.f) + 1.f;
180 return std::sin(13.f * kPi2 * p) * std::pow(2.f, 10.f * (p - 1.f));
187 return std::sin(-13.f * kPi2 * (p + 1.f)) * std::pow(2.f, -10.f * p) + 1.f;
195 return 0.5f * std::sin(13.f * kPi2 * (2.f * p)) *
196 std::pow(2.f, 10.f * ((2.f * p) - 1.f));
198 return 0.5f * (std::sin(-13.f * kPi2 * ((2.f * p - 1.f) + 1.f)) *
199 std::pow(2.f, -10.f * (2.f * p - 1.f)) +
205 return p * p * p - p * std::sin(p * kPi);
210 const float f = (1.f - p);
211 return 1.f - (f * f * f - f * std::sin(f * kPi));
219 const float f = 2.f * p;
220 return 0.5f * (f * f * f - f * std::sin(f * kPi));
222 const float f = (1.f - (2.f * p - 1.f));
223 return 0.5f * (1.f - (f * f * f - f * std::sin(f * kPi))) + 0.5f;
231 if (p < 4.f / 11.f) {
232 return (121.f * p * p) / 16.f;
235 if (p < 8.f / 11.f) {
236 return (363.f / 40.f * p * p) - (99.f / 10.f * p) + 17.f / 5.f;
239 if (p < 9.f / 10.f) {
240 return (4356.f / 361.f * p * p) - (35442.f / 1805.f * p) +
244 return (54.f / 5.f * p * p) - (513 / 25.f * p) + 268 / 25.f;
251 return 0.5f *
BounceOut(p * 2.f - 1.f) + 0.5f;
265 easing_function_(std::move(easing_function)),
273 if (current_ >= duration_) {
282 (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< float > Duration
void RequestAnimationFrame()