25#ifndef TWEENY_DETAIL_EASING_BOUNCE_H
26#define TWEENY_DETAIL_EASING_BOUNCE_H
28namespace tweeny::detail {
29 struct bounceOutEasing {
31 static T run(
float position, T start, T end) {
33 if (position < 1 / 2.75f) {
34 return static_cast<T
>(c * (7.5625f * position * position) + start);
36 if (position < 2.0f / 2.75f) {
37 const float postFix = position -= 1.5f / 2.75f;
38 return static_cast<T
>(c * (7.5625f * (postFix) * position + .75f) + start);
40 if (position < 2.5f / 2.75f) {
41 const float postFix = position -= 2.25f / 2.75f;
42 return static_cast<T
>(c * (7.5625f * postFix * position + .9375f) + start);
44 const float postFix = position -= (2.625f / 2.75f);
45 return static_cast<T
>(c * (7.5625f * postFix * position + .984375f) + start);
49 T operator()(
const float position, T start, T end)
const {
50 return run<T>(position, start, end);
54 struct bounceInEasing {
56 static T run(
const float position, T start, T end) {
57 return end - start - bounceOutEasing::run(1 - position, T(), (end - start)) + start;
61 T operator()(
const float position, T start, T end)
const {
62 return run<T>(position, start, end);
66 struct bounceInOutEasing {
68 static T run(
const float position, T start, T end) {
69 if (position < 0.5f)
return static_cast<T
>(bounceInEasing::run(position * 2, T(), end - start) * .5f + start);
70 return static_cast<T
>(bounceOutEasing::run(position * 2 - 1, T(), end - start) * .5f + (end - start) * .5f +
75 T operator()(
float position, T start, T end)
const {
76 return run<T>(position, start, end);