12constexpr float kPi = 3.14159265358979323846f;
13constexpr float kPi2 = kPi / 2.f;
38 return -(p * (p - 2.f));
45 return p < 0.5f ? 2.f * p * p : (-2.f * p * p) + (4.f * p) - 1.f;
55 const float f = (p - 1.f);
56 return f * f * f + 1.f;
64 return 4.f * p * p * p;
66 const float f = ((2.f * p) - 2.f);
67 return 0.5f * f * f * f + 1.f;
77 const float f = (p - 1.f);
78 return f * f * f * (1.f - p) + 1.f;
86 return 8.f * p * p * p * p;
88 const float f = (p - 1.f);
89 return -8.f * f * f * f * f + 1.f;
94 return p * p * p * p * p;
99 const float f = (p - 1.f);
100 return f * f * f * f * f + 1.f;
108 return 16.f * p * p * p * p * p;
110 const float f = ((2.f * p) - 2.f);
111 return 0.5f * f * f * f * f * f + 1.f;
116 return std::sin((p - 1.f) * kPi2) + 1.f;
121 return std::sin(p * kPi2);
126 return 0.5f * (1.f - std::cos(p * kPi));
131 return 1.f - std::sqrt(1.f - (p * p));
136 return std::sqrt((2.f - p) * p);
144 return 0.5f * (1.f - std::sqrt(1.f - 4.f * (p * p)));
146 return 0.5f * (std::sqrt(-((2.f * p) - 3.f) * ((2.f * p) - 1.f)) + 1.f);
151 return (p == 0.f) ? p : std::pow(2.f, 10.f * (p - 1.f));
156 return (p == 1.f) ? p : 1.f - std::pow(2.f, -10.f * p);
163 if (p == 0.f || p == 1.f) {
168 return 0.5f * std::pow(2.f, (20.f * p) - 10.f);
170 return -0.5f * std::pow(2.f, (-20.f * p) + 10.f) + 1.f;
175 return std::sin(13.f * kPi2 * p) * std::pow(2.f, 10.f * (p - 1.f));
180 return std::sin(-13.f * kPi2 * (p + 1.f)) * std::pow(2.f, -10.f * p) + 1.f;
188 return 0.5f * std::sin(13.f * kPi2 * (2.f * p)) *
189 std::pow(2.f, 10.f * ((2.f * p) - 1.f));
191 return 0.5f * (std::sin(-13.f * kPi2 * ((2.f * p - 1.f) + 1.f)) *
192 std::pow(2.f, -10.f * (2.f * p - 1.f)) +
198 return p * p * p - p * std::sin(p * kPi);
203 const float f = (1.f - p);
204 return 1.f - (f * f * f - f * std::sin(f * kPi));
212 const float f = 2.f * p;
213 return 0.5f * (f * f * f - f * std::sin(f * kPi));
215 const float f = (1.f - (2.f * p - 1.f));
216 return 0.5f * (1.f - (f * f * f - f * std::sin(f * kPi))) + 0.5f;
224 if (p < 4.f / 11.f) {
225 return (121.f * p * p) / 16.f;
228 if (p < 8.f / 11.f) {
229 return (363.f / 40.f * p * p) - (99.f / 10.f * p) + 17.f / 5.f;
232 if (p < 9.f / 10.f) {
233 return (4356.f / 361.f * p * p) - (35442.f / 1805.f * p) + 16061.f / 1805.f;
236 return (54.f / 5.f * p * p) - (513 / 25.f * p) + 268 / 25.f;
243 return 0.5f *
BounceOut(p * 2.f - 1.f) + 0.5f;
257 easing_function_(std::move(easing_function)),
265 if (current_ >= duration_) {
273 *value_ = from_ + (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
此动画步骤表示的持续时间。
void RequestAnimationFrame()
RequestAnimationFrame 是一个请求在下一个动画周期中绘制新帧的函数。
FTXUI ftxui::animation::easing:: 命名空间
float CircularInOut(float p)
float BounceInOut(float p)
float CubicInOut(float p)
float Linear(float p)
模仿直线 y = x
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)
模仿抛物线 y = x^2
float ExponentialIn(float p)
float ElasticOut(float p)
std::function< float(float)> Function
float QuinticInOut(float p)
FTXUI ftxui::animation:: 命名空间
std::chrono::duration< float > Duration