Compare commits

...

2 Commits

Author SHA1 Message Date
bca2439c15 static fix 2025-02-27 10:53:35 +03:00
2de931e9a6 add const 2025-02-27 10:06:26 +03:00
2 changed files with 33 additions and 33 deletions

View File

@ -2,57 +2,57 @@
namespace EasingFunc { namespace EasingFunc {
typedef float(*eFunc)(float); typedef float(*eFunc)(float);
float easeLinear(float t) { static float easeLinear(float t) {
return t; return t;
} }
float easeInSine(float t) { static float easeInSine(float t) {
return sin(1.5707963 * t); return sin(1.5707963 * t);
} }
float easeOutSine(float t) { static float easeOutSine(float t) {
return 1 + sin(1.5707963 * (--t)); return 1 + sin(1.5707963 * (--t));
} }
float easeInOutSine(float t) { static float easeInOutSine(float t) {
return 0.5 * (1 + sin(3.1415926 * (t - 0.5))); return 0.5 * (1 + sin(3.1415926 * (t - 0.5)));
} }
float easeInQuad(float t) { static float easeInQuad(float t) {
return t * t; return t * t;
} }
float easeOutQuad(float t) { static float easeOutQuad(float t) {
return t * (2 - t); return t * (2 - t);
} }
float easeInOutQuad(float t) { static float easeInOutQuad(float t) {
return t < 0.5 ? 2 * t * t : t * (4 - 2 * t) - 1; return t < 0.5 ? 2 * t * t : t * (4 - 2 * t) - 1;
} }
float easeInCubic(float t) { static float easeInCubic(float t) {
return t * t * t; return t * t * t;
} }
float easeOutCubic(float t) { static float easeOutCubic(float t) {
return 1 + (--t) * t * t; return 1 + (--t) * t * t;
} }
float easeInOutCubic(float t) { static float easeInOutCubic(float t) {
return t < 0.5 ? 4 * t * t * t : 1 + (--t) * (2 * (--t)) * (2 * t); return t < 0.5 ? 4 * t * t * t : 1 + (--t) * (2 * (--t)) * (2 * t);
} }
float easeInQuart(float t) { static float easeInQuart(float t) {
t *= t; t *= t;
return t * t; return t * t;
} }
float easeOutQuart(float t) { static float easeOutQuart(float t) {
t = (--t) * t; t = (--t) * t;
return 1 - t * t; return 1 - t * t;
} }
float easeInOutQuart(float t) { static float easeInOutQuart(float t) {
if (t < 0.5) { if (t < 0.5) {
t *= t; t *= t;
return 8 * t * t; return 8 * t * t;
@ -62,17 +62,17 @@ namespace EasingFunc {
} }
} }
float easeInQuint(float t) { static float easeInQuint(float t) {
float t2 = t * t; float t2 = t * t;
return t * t2 * t2; return t * t2 * t2;
} }
float easeOutQuint(float t) { static float easeOutQuint(float t) {
float t2 = (--t) * t; float t2 = (--t) * t;
return 1 + t * t2 * t2; return 1 + t * t2 * t2;
} }
float easeInOutQuint(float t) { static float easeInOutQuint(float t) {
float t2; float t2;
if (t < 0.5) { if (t < 0.5) {
t2 = t * t; t2 = t * t;
@ -83,15 +83,15 @@ namespace EasingFunc {
} }
} }
float easeInExpo(float t) { static float easeInExpo(float t) {
return (pow(2, 8 * t) - 1) / 255; return (pow(2, 8 * t) - 1) / 255;
} }
float easeOutExpo(float t) { static float easeOutExpo(float t) {
return 1 - pow(2, -8 * t); return 1 - pow(2, -8 * t);
} }
float easeInOutExpo(float t) { static float easeInOutExpo(float t) {
if (t < 0.5) { if (t < 0.5) {
return (pow(2, 16 * t) - 1) / 510; return (pow(2, 16 * t) - 1) / 510;
} else { } else {
@ -99,15 +99,15 @@ namespace EasingFunc {
} }
} }
float easeInCirc(float t) { static float easeInCirc(float t) {
return 1 - sqrt(1 - t); return 1 - sqrt(1 - t);
} }
float easeOutCirc(float t) { static float easeOutCirc(float t) {
return sqrt(t); return sqrt(t);
} }
float easeInOutCirc(float t) { static float easeInOutCirc(float t) {
if (t < 0.5) { if (t < 0.5) {
return (1 - sqrt(1 - 2 * t)) * 0.5; return (1 - sqrt(1 - 2 * t)) * 0.5;
} else { } else {
@ -115,15 +115,15 @@ namespace EasingFunc {
} }
} }
float easeInBack(float t) { static float easeInBack(float t) {
return t * t * (2.70158 * t - 1.70158); return t * t * (2.70158 * t - 1.70158);
} }
float easeOutBack(float t) { static float easeOutBack(float t) {
return 1 + (--t) * t * (2.70158 * t + 1.70158); return 1 + (--t) * t * (2.70158 * t + 1.70158);
} }
float easeInOutBack(float t) { static float easeInOutBack(float t) {
if (t < 0.5) { if (t < 0.5) {
return t * t * (7 * t - 2.5) * 2; return t * t * (7 * t - 2.5) * 2;
} else { } else {
@ -131,17 +131,17 @@ namespace EasingFunc {
} }
} }
float easeInElastic(float t) { static float easeInElastic(float t) {
float t2 = t * t; float t2 = t * t;
return t2 * t2 * sin(t * PI * 4.5); return t2 * t2 * sin(t * PI * 4.5);
} }
float easeOutElastic(float t) { static float easeOutElastic(float t) {
float t2 = (t - 1) * (t - 1); float t2 = (t - 1) * (t - 1);
return 1 - t2 * t2 * cos(t * PI * 4.5); return 1 - t2 * t2 * cos(t * PI * 4.5);
} }
float easeInOutElastic(float t) { static float easeInOutElastic(float t) {
float t2; float t2;
if (t < 0.45) { if (t < 0.45) {
t2 = t * t; t2 = t * t;
@ -154,15 +154,15 @@ namespace EasingFunc {
} }
} }
float easeInBounce(float t) { static float easeInBounce(float t) {
return pow(2, 6 * (t - 1)) * abs(sin(t * PI * 3.5)); return pow(2, 6 * (t - 1)) * abs(sin(t * PI * 3.5));
} }
float easeOutBounce(float t) { static float easeOutBounce(float t) {
return 1 - pow(2, -6 * t) * abs(cos(t * PI * 3.5)); return 1 - pow(2, -6 * t) * abs(cos(t * PI * 3.5));
} }
float easeInOutBounce(float t) { static float easeInOutBounce(float t) {
if (t < 0.5) { if (t < 0.5) {
return 8 * pow(2, 8 * (t - 1)) * abs(sin(t * PI * 7)); return 8 * pow(2, 8 * (t - 1)) * abs(sin(t * PI * 7));
} else { } else {

View File

@ -84,7 +84,7 @@ public:
isPlayingF = false; isPlayingF = false;
} }
bool isPlaying() { bool isPlaying() const {
return isPlayingF; return isPlayingF;
} }