22#include <kiwano/math/Scalar.h>
29inline float Linear(
float step)
36inline float EaseIn(
float step,
float rate)
38 return math::Pow(step, rate);
41inline float EaseOut(
float step,
float rate)
43 return math::Pow(step, 1.f / rate);
46inline float EaseInOut(
float step,
float rate)
49 return .5f * math::Pow(2 * step, rate);
50 return 1.f - .5f * math::Pow(2.f - 2 * step, rate);
55inline float EaseExponentialIn(
float step)
57 return math::Pow(2.f, 10 * (step - 1));
60inline float EaseExponentialOut(
float step)
62 return 1.f - math::Pow(2.f, -10 * step);
65inline float EaseExponentialInOut(
float step)
68 return .5f * math::Pow(2.f, 10 * (2 * step - 1));
69 return 0.5f * (2 - math::Pow(2, -10 * (step * 2 - 1)));
74inline float EaseBounceOut(
float step)
78 return 7.5625f * step * step;
80 else if (step < 2 / 2.75f)
83 return 7.5625f * step * step + 0.75f;
85 else if (step < 2.5f / 2.75f)
87 step -= 2.25f / 2.75f;
88 return 7.5625f * step * step + 0.9375f;
91 step -= 2.625f / 2.75f;
92 return 7.5625f * step * step + 0.984375f;
95inline float EaseBounceIn(
float step)
97 return 1 - EaseBounceOut(1 - step);
100inline float EaseBounceInOut(
float step)
104 return EaseBounceIn(step * 2) * 0.5f;
108 return EaseBounceOut(step * 2 - 1) * 0.5f + 0.5f;
114inline float EaseElasticIn(
float step,
float period)
116 if (step == 0 || step == 1)
120 return -math::Pow(2, 10 * step) * math::Sin((step - period / 4) * 360.f / period);
123inline float EaseElasticOut(
float step,
float period)
125 if (step == 0 || step == 1)
128 return math::Pow(2, -10 * step) * math::Sin((step - period / 4) * 360.f / period) + 1;
131inline float EaseElasticInOut(
float step,
float period)
133 if (step == 0 || step == 1)
139 return -0.5f * math::Pow(2, 10 * step) * math::Sin((step - period / 4) * 360.f / period);
141 return math::Pow(2, -10 * step) * math::Sin((step - period / 4) * 360.f / period) * 0.5f + 1;
146inline float EaseBackIn(
float step)
148 const float overshoot = 1.70158f;
149 return step * step * ((overshoot + 1) * step - overshoot);
152inline float EaseBackOut(
float step)
154 const float overshoot = 1.70158f;
156 return step * step * ((overshoot + 1) * step + overshoot) + 1;
159inline float EaseBackInOut(
float step)
161 const float overshoot = 1.70158f * 1.525f;
166 return (step * step * ((overshoot + 1) * step - overshoot)) / 2;
170 return (step * step * ((overshoot + 1) * step + overshoot)) / 2 + 1;
175inline float EaseSineIn(
float step)
177 return 1.f - math::Cos(step * 90);
180inline float EaseSineOut(
float step)
182 return math::Sin(step * 90);
185inline float EaseSineInOut(
float step)
187 return -0.5f * (math::Cos(step * 180) - 1);
192inline float EaseQuadIn(
float step)
197inline float EaseQuadOut(
float step)
199 return -1 * step * (step - 2);
202inline float EaseQuadInOut(
float step)
206 return 0.5f * step * step;
208 return -0.5f * (step * (step - 2) - 1);
213inline float EaseCubicIn(
float step)
215 return step * step * step;
218inline float EaseCubicOut(
float step)
221 return (step * step * step + 1);
224inline float EaseCubicInOut(
float step)
228 return 0.5f * step * step * step;
230 return 0.5f * (step * step * step + 2);
235inline float EaseQuartIn(
float step)
237 return step * step * step * step;
240inline float EaseQuartOut(
float step)
243 return -(step * step * step * step - 1);
246inline float EaseQuartInOut(
float step)
250 return 0.5f * step * step * step * step;
252 return -0.5f * (step * step * step * step - 2);
257inline float EaseQuintIn(
float step)
259 return step * step * step * step * step;
262inline float EaseQuintOut(
float step)
265 return (step * step * step * step * step + 1);
268inline float EaseQuintInOut(
float step)
272 return 0.5f * step * step * step * step * step;
274 return 0.5f * (step * step * step * step * step + 2);