Last active
March 20, 2025 08:54
-
-
Save nicoplv/6313e6dba20be517e5b463f51d042c76 to your computer and use it in GitHub Desktop.
A group of easing functions in Verse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Easing<public> := module : | |
InSine<public>(t:float)<transacts>:float= | |
return 1.0 - Cos(t * PiFloat / 2.0) | |
OutSine<public>(t:float)<transacts>:float= | |
return Sin(t * PiFloat / 2.0) | |
InOutSine<public>(t:float)<transacts>:float= | |
return (Cos(t * PiFloat) - 1.0) / -2.0 | |
InQuad<public>(t:float)<transacts>:float= | |
t * t | |
OutQuad<public>(t:float)<transacts>:float= | |
1.0 - InQuad(1.0 - t) | |
InOutQuad<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
InQuad(t * 2.0) / 2.0 | |
else: | |
1.0 - InQuad((1.0 - t) * 2.0) / 2.0 | |
InBack<public>(t:float)<transacts>:float= | |
s := 1.70158; | |
return t * t * ((s + 1.0) * t - s); | |
OutBack<public>(t:float)<transacts>:float= | |
1.0 - InBack(1.0 - t); | |
InOutBack<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InBack(t * 2.0) / 2.0; | |
else: | |
return 1.0 - InBack((1.0 - t) * 2.0) / 2.0 | |
InCubic<public>(t:float)<transacts>:float= | |
return t * t * t | |
OutCubic<public>(t:float)<transacts>:float= | |
return 1.0 - InCubic(1.0 - t) | |
InOutCubic<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InCubic(t * 2.0) / 2.0 | |
else: | |
return 1.0 - InCubic((1.0 - t) * 2.0) / 2.0 | |
InQuart<public>(t:float)<transacts>:float= | |
return t * t * t * t | |
OutQuart<public>(t:float)<transacts>:float= | |
return 1.0 - InQuart(1.0 - t) | |
InOutQuart<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InQuart(t * 2.0) / 2.0 | |
else: | |
return 1.0 - InQuart((1.0 - t) * 2.0) / 2.0 | |
InQuint<public>(t:float)<transacts>:float= | |
return t * t * t * t * t | |
OutQuint<public>(t:float)<transacts>:float= | |
return 1.0 - InQuint(1.0 - t) | |
InOutQuint<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InQuint(t * 2.0) / 2.0 | |
else: | |
return 1.0 - InQuint((1.0 - t) * 2.0) / 2.0 | |
InExpo<public>(t:float)<transacts>:float= | |
return Pow(2.0, 10.0 * (t - 1.0)) | |
OutExpo<public>(t:float)<transacts>:float= | |
return 1.0 - InExpo(1.0 - t) | |
InOutExpo<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InExpo(t * 2.0) / 2.0 | |
else: | |
return 1.0 - InExpo((1.0 - t) * 2.0) / 2.0 | |
InCirc<public>(t:float)<transacts>:float= | |
return -(Sqrt(1.0 - t * t) - 1.0) | |
OutCirc<public>(t:float)<transacts>:float= | |
return 1.0 - InCirc(1.0 - t) | |
InOutCirc<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InCirc(t * 2.0) / 2.0 | |
else: | |
return 1.0 - InCirc((1.0 - t) * 2.0) / 2.0 | |
InElastic<public>(t:float)<transacts>:float= | |
return 1.0 - OutElastic(1.0 - t) | |
OutElastic<public>(t:float)<transacts>:float= | |
p := 0.3 | |
return Pow(2.0, -10.0 * t) * Sin((t - p / 4.0) * (2.0 * PiFloat) / p) + 1.0 | |
InOutElastic<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InElastic(t * 2.0) / 2.0 | |
else: | |
return 1.0 - InElastic((1.0 - t) * 2.0) / 2.0 | |
InBounce<public>(t:float)<transacts>:float= | |
return 1.0 - OutBounce(1.0 - t) | |
OutBounce<public>(t:float)<transacts>:float= | |
div := 2.75 | |
mult := 7.5625 | |
if(t < 1.0 / div): | |
return mult * t * t | |
else if(t < 2.0 / div): | |
bT := t - 1.5 / div | |
return mult * bT * bT + 0.75 | |
else if(t < 2.5 / div): | |
bT := t - 2.25 / div | |
return mult * bT * bT + 0.9375 | |
else: | |
bT := t - 2.625 / div | |
return mult * bT * bT + 0.984375 | |
InOutBounce<public>(t:float)<transacts>:float= | |
if(t < 0.5): | |
return InBounce(t * 2.0) / 2.0 | |
else: | |
return 1.0 - InBounce((1.0 - t) * 2.0) / 2.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment