mirror of
https://github.com/Show-maket/Tween.git
synced 2025-05-04 23:30:20 +00:00
Compare commits
No commits in common. "bca2439c15a21251fffbd06561901770341f2c12" and "2a8fba23d3738064226cd520003b951a75784d28" have entirely different histories.
bca2439c15
...
2a8fba23d3
62
Easing.h
62
Easing.h
@ -2,57 +2,57 @@
|
|||||||
namespace EasingFunc {
|
namespace EasingFunc {
|
||||||
typedef float(*eFunc)(float);
|
typedef float(*eFunc)(float);
|
||||||
|
|
||||||
static float easeLinear(float t) {
|
float easeLinear(float t) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInSine(float t) {
|
float easeInSine(float t) {
|
||||||
return sin(1.5707963 * t);
|
return sin(1.5707963 * t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutSine(float t) {
|
float easeOutSine(float t) {
|
||||||
return 1 + sin(1.5707963 * (--t));
|
return 1 + sin(1.5707963 * (--t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutSine(float t) {
|
float easeInOutSine(float t) {
|
||||||
return 0.5 * (1 + sin(3.1415926 * (t - 0.5)));
|
return 0.5 * (1 + sin(3.1415926 * (t - 0.5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInQuad(float t) {
|
float easeInQuad(float t) {
|
||||||
return t * t;
|
return t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutQuad(float t) {
|
float easeOutQuad(float t) {
|
||||||
return t * (2 - t);
|
return t * (2 - t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutQuad(float t) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInCubic(float t) {
|
float easeInCubic(float t) {
|
||||||
return t * t * t;
|
return t * t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutCubic(float t) {
|
float easeOutCubic(float t) {
|
||||||
return 1 + (--t) * t * t;
|
return 1 + (--t) * t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutCubic(float t) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInQuart(float t) {
|
float easeInQuart(float t) {
|
||||||
t *= t;
|
t *= t;
|
||||||
return t * t;
|
return t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutQuart(float t) {
|
float easeOutQuart(float t) {
|
||||||
t = (--t) * t;
|
t = (--t) * t;
|
||||||
return 1 - t * t;
|
return 1 - t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutQuart(float t) {
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInQuint(float t) {
|
float easeInQuint(float t) {
|
||||||
float t2 = t * t;
|
float t2 = t * t;
|
||||||
return t * t2 * t2;
|
return t * t2 * t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutQuint(float t) {
|
float easeOutQuint(float t) {
|
||||||
float t2 = (--t) * t;
|
float t2 = (--t) * t;
|
||||||
return 1 + t * t2 * t2;
|
return 1 + t * t2 * t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutQuint(float t) {
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInExpo(float t) {
|
float easeInExpo(float t) {
|
||||||
return (pow(2, 8 * t) - 1) / 255;
|
return (pow(2, 8 * t) - 1) / 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutExpo(float t) {
|
float easeOutExpo(float t) {
|
||||||
return 1 - pow(2, -8 * t);
|
return 1 - pow(2, -8 * t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutExpo(float t) {
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInCirc(float t) {
|
float easeInCirc(float t) {
|
||||||
return 1 - sqrt(1 - t);
|
return 1 - sqrt(1 - t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutCirc(float t) {
|
float easeOutCirc(float t) {
|
||||||
return sqrt(t);
|
return sqrt(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutCirc(float t) {
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInBack(float t) {
|
float easeInBack(float t) {
|
||||||
return t * t * (2.70158 * t - 1.70158);
|
return t * t * (2.70158 * t - 1.70158);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutBack(float t) {
|
float easeOutBack(float t) {
|
||||||
return 1 + (--t) * t * (2.70158 * t + 1.70158);
|
return 1 + (--t) * t * (2.70158 * t + 1.70158);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutBack(float t) {
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInElastic(float t) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutElastic(float t) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutElastic(float t) {
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInBounce(float t) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeOutBounce(float t) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
static float easeInOutBounce(float t) {
|
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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user