31 #ifndef TWEENY_EASING_H 32 #define TWEENY_EASING_H 35 #include <type_traits> 38 #define M_PI 3.14159265358979323846 128 static typename std::enable_if<std::is_integral<T>::value, T>::type run(
float position, T start, T end) {
129 return static_cast<T
>(roundf((end - start) * position + start));
133 static typename std::enable_if<!std::is_integral<T>::value, T>::type run(
float position, T start, T end) {
134 return static_cast<T
>((end - start) * position + start);
144 static T run(
float position, T start, T end) {
145 return static_cast<T
>((end - start) * position * position + start);
155 static T run(
float position, T start, T end) {
156 return static_cast<T
>((-(end - start)) * position * (position - 2) + start);
166 static T run(
float position, T start, T end) {
169 return static_cast<T
>(((end - start) / 2) * position * position + start);
173 return static_cast<T
>((-(end - start) / 2) * (position * (position - 2) - 1) + start);
183 static T run(
float position, T start, T end) {
184 return static_cast<T
>((end - start) * position * position * position + start);
194 static T run(
float position, T start, T end) {
196 return static_cast<T
>((end - start) * (position * position * position + 1) + start);
206 static T run(
float position, T start, T end) {
209 return static_cast<T
>(((end - start) / 2) * position * position * position + start);
212 return static_cast<T
>(((end - start) / 2) * (position * position * position + 2) + start);
222 static T run(
float position, T start, T end) {
223 return static_cast<T
>((end - start) * position * position * position * position + start);
233 static T run(
float position, T start, T end) {
235 return static_cast<T
>( -(end - start) * (position * position * position * position - 1) + start);
245 static T run(
float position, T start, T end) {
248 return static_cast<T
>(((end - start) / 2) * (position * position * position * position) +
252 return static_cast<T
>((-(end - start) / 2) * (position * position * position * position - 2) +
263 static T run(
float position, T start, T end) {
264 return static_cast<T
>((end - start) * position * position * position * position * position + start);
274 static T run(
float position, T start, T end) {
276 return static_cast<T
>((end - start) * (position * position * position * position * position + 1) +
287 static T run(
float position, T start, T end) {
290 return static_cast<T
>(
291 ((end - start) / 2) * (position * position * position * position * position) +
295 return static_cast<T
>(
296 ((end - start) / 2) * (position * position * position * position * position + 2) +
307 static T run(
float position, T start, T end) {
308 return static_cast<T
>(-(end - start) * cosf(position * static_cast<float>(M_PI) / 2) + (end - start) + start);
318 static T run(
float position, T start, T end) {
319 return static_cast<T
>((end - start) * sinf(position * static_cast<float>(M_PI) / 2) + start);
329 static T run(
float position, T start, T end) {
330 return static_cast<T
>((-(end - start) / 2) * (cosf(position * static_cast<float>(M_PI)) - 1) + start);
340 static T run(
float position, T start, T end) {
341 return static_cast<T
>((end - start) * powf(2, 10 * (position - 1)) + start);
351 static T run(
float position, T start, T end) {
352 return static_cast<T
>((end - start) * (-powf(2, -10 * position) + 1) + start);
362 static T run(
float position, T start, T end) {
365 return static_cast<T
>(((end - start) / 2) * powf(2, 10 * (position - 1)) + start);
368 return static_cast<T
>(((end - start) / 2) * (-powf(2, -10 * position) + 2) + start);
378 static T run(
float position, T start, T end) {
379 return static_cast<T
>( -(end - start) * (sqrtf(1 - position * position) - 1) + start );
389 static T run(
float position, T start, T end) {
391 return static_cast<T
>((end - start) * (sqrtf(1 - position * position)) + start);
401 static T run(
float position, T start, T end) {
404 return static_cast<T
>((-(end - start) / 2) * (sqrtf(1 - position * position) - 1) + start);
408 return static_cast<T
>(((end - start) / 2) * (sqrtf(1 - position * position) + 1) + start);
418 static T run(
float position, T start, T end) {
419 return (end - start) - bounceOut.run((1 - position), T(), end) + start;
429 static T run(
float position, T start, T end) {
431 if (position < (1 / 2.75f)) {
432 return static_cast<T
>(c * (7.5625f * position * position) + start);
433 }
else if (position < (2.0f / 2.75f)) {
434 float postFix = position -= (1.5f / 2.75f);
435 return static_cast<T
>(c * (7.5625f * (postFix) * position + .75f) + start);
436 }
else if (position < (2.5f / 2.75f)) {
437 float postFix = position -= (2.25f / 2.75f);
438 return static_cast<T
>(c * (7.5625f * (postFix) * position + .9375f) + start);
440 float postFix = position -= (2.625f / 2.75f);
441 return static_cast<T
>(c * (7.5625f * (postFix) * position + .984375f) + start);
452 static T run(
float position, T start, T end) {
453 if (position < 0.5f)
return static_cast<T
>(bounceIn.run(position * 2, T(), end) * .5f + start);
454 else return static_cast<T
>(bounceOut.run((position * 2 - 1), T(), end) * .5f + (end - start) * .5f + start);
464 static T run(
float position, T start, T end) {
465 if (position <= 0.00001f)
return start;
466 if (position >= 0.999f)
return end;
468 float a = end - start;
471 a * powf(2, 10 * (position -= 1));
472 return static_cast<T
>(-(postFix * sinf((position - s) * (2 * static_cast<float>(M_PI)) / p)) + start);
482 static T run(
float position, T start, T end) {
483 if (position <= 0.00001f)
return start;
484 if (position >= 0.999f)
return end;
486 float a = end - start;
488 return static_cast<T
>(a * powf(2, -10 * position) * sinf((position - s) * (2 * static_cast<float>(M_PI)) / p) + end);
498 static T run(
float position, T start, T end) {
499 if (position <= 0.00001f)
return start;
500 if (position >= 0.999f)
return end;
502 float p = (.3f * 1.5f);
503 float a = end - start;
508 postFix = a * powf(2, 10 * (position -= 1));
509 return static_cast<T
>(-0.5f * (postFix * sinf((position - s) * (2 * static_cast<float>(M_PI)) / p)) + start);
511 postFix = a * powf(2, -10 * (position -= 1));
512 return static_cast<T
>(postFix * sinf((position - s) * (2 * static_cast<float>(M_PI)) / p) * .5f + end);
522 static T run(
float position, T start, T end) {
524 float postFix = position;
525 return static_cast<T
>((end - start) * (postFix) * position * ((s + 1) * position - s) + start);
535 static T run(
float position, T start, T end) {
538 return static_cast<T
>((end - start) * ((position) * position * ((s + 1) * position + s) + 1) + start);
548 static T run(
float position, T start, T end) {
555 if ((t /= d / 2) < 1)
return static_cast<T>(c / 2 * (t * t * (((s) + 1) * t - s)) + b);
556 float postFix = t -= 2;
557 return static_cast<T
>(c / 2 * ((postFix) * t * (((s) + 1) * t + s) + 2) + b);
562 #endif //TWEENY_EASING_H Acceelerate initial values with a "back" equation.
Definition: easing.h:520
Acceelerate initial and deaccelerate ending values with a quartic equation.
Definition: easing.h:243
Deaccelerate ending values with a "bounce" equation.
Definition: easing.h:427
Acceelerate initial and deaccelerate ending values with a cubic equation.
Definition: easing.h:204
Acceelerate initial values with an "elastic" equation.
Definition: easing.h:462
The tweeny namespace contains all symbols and names for the Tweeny library.
Definition: MANUAL.dox:1
Acceelerate initial and deaccelerate ending values with an "elastic" equation.
Definition: easing.h:496
Acceelerate initial and deaccelerate ending values with a "back" equation.
Definition: easing.h:546
Acceelerate initial values with a quintic equation.
Definition: easing.h:261
Deaccelerate ending values with an exponential equation.
Definition: easing.h:349
Acceelerate initial values with a quartic equation.
Definition: easing.h:220
Accelerate initial values with a quadratic equation.
Definition: easing.h:142
Acceelerate initial and deaccelerate ending values with a circular equation.
Definition: easing.h:399
Deaccelerate ending values with a circular equation.
Definition: easing.h:387
Deaccelerate ending values with a cubic equation.
Definition: easing.h:192
Deaccelerate ending values with an "elastic" equation.
Definition: easing.h:480
Acceelerate initial and deaccelerate ending values with a "bounce" equation.
Definition: easing.h:450
Deaccelerate ending values with a sinusoidal equation.
Definition: easing.h:316
Acceelerate initial values with a "bounce" equation.
Definition: easing.h:416
Acceelerate initial and deaccelerate ending values with a quadratic equation.
Definition: easing.h:164
Deaccelerate ending values with a "back" equation.
Definition: easing.h:533
Deaccelerate ending values with a quartic equation.
Definition: easing.h:231
Values change with constant speed.
Definition: easing.h:126
Deaccelerate ending values with a quadratic equation.
Definition: easing.h:153
Acceelerate initial values with an exponential equation.
Definition: easing.h:338
Acceelerate initial and deaccelerate ending values with an exponential equation.
Definition: easing.h:360
The easing class holds all the bundled easings.
Definition: easing.h:120
Acceelerate initial values with a sinusoidal equation.
Definition: easing.h:305
Acceelerate initial and deaccelerate ending values with a sinusoidal equation.
Definition: easing.h:327
Deaccelerate ending values with a quintic equation.
Definition: easing.h:272
Aaccelerate initial values with a cubic equation.
Definition: easing.h:181
Acceelerate initial values with a circular equation.
Definition: easing.h:376
Acceelerate initial and deaccelerate ending values with a quintic equation.
Definition: easing.h:285