19typedef enum : uint16_t {
35static inline float easeInSine(
float t)
37 return sinf(1.5707963f * t);
40static inline float easeOutSine(
float t)
42 return 1.0f + sinf(1.5707963f * (t - 1.0f));
45static inline float easeInOutSine(
float t)
47 return 0.5f * (1.0f + sinf(3.1415926f * (t - 0.5f)));
50static inline float easeInQuad(
float t)
55static inline float easeOutQuad(
float t)
57 return t * (2.0f - t);
60static inline float easeInOutQuad(
float t)
64 t * (4.0f - 2.0f * t) - 1.0f;
67static inline float easeInCubic(
float t)
72static inline float easeOutCubic(
float t)
75 return 1.0f + t * t * t;
78static inline float easeInOutCubic(
float t)
81 return 4.0f * t * t * t;
84 return 1.0f + 4.0f * t * t * t;
88static inline float easeInQuart(
float t)
94static inline float easeOutQuart(
float t)
96 t = (t - 1.0f) * (t - 1.0f);
100static inline float easeInOutQuart(
float t)
106 t = (t - 1.0f) * (t - 1.0f);
107 return 1.0f - 8.0f * t * t;
111static inline float easeInQuint(
float t)
117static inline float easeOutQuint(
float t)
121 return 1.0f + t * t2 * t2;
124static inline float easeInOutQuint(
float t)
129 return 16.0f * t * t2 * t2;
133 return 1.0f + 16.0f * t * t2 * t2;
137static inline float easeInExpo(
float t)
139 return (powf(2.0f, 8.0f * t) - 1.0f) / 256.0f;
142static inline float easeOutExpo(
float t)
144 return 1.0f - powf(2.0f, -8.0f * t);
147static inline float easeInOutExpo(
float t)
150 return (powf(2.0f, 16.0f * t) - 1.0f) / 512.0f;
152 return 1.0f - 0.5f * powf(2.0f, -16.0f * (t - 0.5f));
156static inline float easeInCirc(
float t)
158 return 1.0f - sqrtf(1.0f - t);
161static inline float easeOutCirc(
float t)
166static inline float easeInOutCirc(
float t)
169 return (1.0f - sqrtf(1.0f - 2.0f * t)) * 0.5f;
171 return (1.0f + sqrtf(2.0f * t - 1.0f)) * 0.5f;
175static inline float easeInBack(
float t)
177 return t * t * (2.70158f * t - 1.70158f);
180static inline float easeOutBack(
float t)
183 return 1.0f + t * t * (2.70158f * t + 1.70158f);
186static inline float easeInOutBack(
float t)
189 return t * t * (7.0f * t - 2.5f) * 2.0f;
192 return 1.0f + t * t * 2.0f * (7.0f * t + 2.5f);
196static inline float easeInElastic(
float t)
199 return t2 * t2 * sinf(t * 3.1415926f * 4.5f);
202static inline float easeOutElastic(
float t)
204 float t2 = (t - 1.0f) * (t - 1.0f);
205 return 1.0f - t2 * t2 * cosf(t * 3.1415926f * 4.5f);
208static inline float easeInOutElastic(
float t)
213 return 8.0f * t2 * t2 * sinf(t * 3.1415926f * 9.0f);
214 }
else if (t < 0.55f) {
215 return 0.5f + 0.75f * sinf(t * 3.1415926f * 4.0f);
217 t2 = (t - 1.0f) * (t - 1.0f);
218 return 1.0f - 8.0f * t2 * t2 * sinf(t * 3.1415926f * 9.0f);
222static inline float easeInBounce(
float t)
224 return powf(2.0f, 6.0f * (t - 1.0f)) * fabsf(sinf(t * 3.1415926f * 3.5f));
227static inline float easeOutBounce(
float t)
229 return 1.0f - powf(2.0f, -6.0f * t) * fabsf(cosf(t * 3.1415926f * 3.5f));
232static inline float easeInOutBounce(
float t)
235 return 8.0f * powf(2.0f, 8.0f * (t - 1.0f)) * fabsf(sinf(t * 3.1415926f * 7.0f));
237 return 1.0f - 8.0f * powf(2.0f, -8.0f * t) * fabsf(sinf(t * 3.1415926f * 7.0f));
248static inline float applyEasing(uint16_t type,
float t)
EASING_TYPES
Definition easings.h:19
@ EASING_OUT_QUART
Definition easings.h:24
@ EASING_IN_EXPO
Definition easings.h:26
@ EASING_IN_BOUNCE
Definition easings.h:30
@ EASING_OUT_QUINT
Definition easings.h:25
@ EASING_OUT_SINE
Definition easings.h:21
@ EASING_IN_OUT_BACK
Definition easings.h:28
@ EASING_IN_SINE
Definition easings.h:21
@ EASING_IN_OUT_SINE
Definition easings.h:21
@ EASING_OUT_CUBIC
Definition easings.h:23
@ EASING_COUNT
Definition easings.h:31
@ EASING_IN_CIRC
Definition easings.h:27
@ EASING_IN_QUINT
Definition easings.h:25
@ EASING_OUT_BOUNCE
Definition easings.h:30
@ EASING_IN_OUT_ELASTIC
Definition easings.h:29
@ EASING_IN_OUT_BOUNCE
Definition easings.h:30
@ EASING_OUT_EXPO
Definition easings.h:26
@ EASING_IN_OUT_EXPO
Definition easings.h:26
@ EASING_IN_ELASTIC
Definition easings.h:29
@ EASING_IN_OUT_QUART
Definition easings.h:24
@ EASING_OUT_BACK
Definition easings.h:28
@ EASING_IN_OUT_QUINT
Definition easings.h:25
@ EASING_OUT_ELASTIC
Definition easings.h:29
@ EASING_IN_QUAD
Definition easings.h:22
@ EASING_IN_CUBIC
Definition easings.h:23
@ EASING_IN_BACK
Definition easings.h:28
@ EASING_IN_OUT_CIRC
Definition easings.h:27
@ EASING_LINEAR
Definition easings.h:20
@ EASING_IN_OUT_QUAD
Definition easings.h:22
@ EASING_IN_OUT_CUBIC
Definition easings.h:23
@ EASING_IN_QUART
Definition easings.h:24
@ EASING_OUT_QUAD
Definition easings.h:22
@ EASING_OUT_CIRC
Definition easings.h:27