25#ifndef TWEENY_DETAIL_EASING_EXPONENTIAL_H
26#define TWEENY_DETAIL_EASING_EXPONENTIAL_H
30namespace tweeny::detail {
31 struct exponentialInEasing {
33 static T run(
const float position, T start, T end) {
34 if (position == 0)
return start;
35 return static_cast<T
>((end - start) * powf(2, 10 * (position - 1)) + start);
39 T operator()(
const float position, T start, T end)
const {
40 return run<T>(position, start, end);
44 struct exponentialOutEasing {
46 static T run(
const float position, T start, T end) {
47 if (position == 1)
return end;
48 return static_cast<T
>((end - start) * (-powf(2, -10 * position) + 1) + start);
52 T operator()(
const float position, T start, T end)
const {
53 return run<T>(position, start, end);
57 struct exponentialInOutEasing {
59 static T run(
float position, T start, T end) {
60 if (position == 0)
return start;
61 if (position == 1)
return end;
64 return static_cast<T
>((end - start) / 2 * powf(2, 10 * (position - 1)) + start);
67 return static_cast<T
>((end - start) / 2 * (-powf(2, -10 * position) + 2) + start);
71 T operator()(
const float position, T start, T end)
const {
72 return run<T>(position, start, end);