# Easing for yall as promised

According to this thread Is there a equivalent for Double for numbers with the help of you wonderul people i’ll give some back

Im a rookie. So this functions aren’t ment for pros, because they do way better.
But for those who still interested, here you go

``````fun backEaseInOut(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {

if (e < r / 2) return backEaseIn(e * 2f, 0f, n, r) * 0.5f + t;
else return backEaseOut(e * 2f - r, 0f, n, r) * 0.5f + n * 0.5f + t

}
fun backEaseOut(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
return 100-backEaseIn(100-e)

}
fun backEaseIn(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
var i = 1.70158f
var de=e/r
return (n * de * de * ((i + 1) * de - i) + t)

}
fun EaseInOut(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {

if (e < r / 2) return EaseIn(e * 2f, 0f, n, r) * 0.5f + t;
else return EaseOut(e * 2f - r, 0f, n, r) * 0.5f + n * 0.5f + t

}
fun EaseOut(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
return 100-EaseIn(100-e)
}
fun EaseIn(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
return n * e / r + t
}
fun  strongEaseInOut(de: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
var e=de
if (e < r / 2) return strongEaseIn(e * 2f, 0f, n, r) * 0.5f + t;
else return strongEaseOut(e * 2f - r, 0f, n, r) * 0.5f + n * 0.5f + t

}
fun strongEaseOut(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
if(e>99){return 100f}
var de=e/r

return 100-strongEaseIn(100-e)
}
fun strongEaseIn(e: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
var de=e
de /= r
return (n * de * e * e * e * e + t)/100000000
}

fun  regularEaseInOut(de: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
var e=de
if (e < r / 2) return regularEaseIn(e * 2f, 0f, n, r) * 0.5f + t;
else return regularEaseOut(e * 2f - r, 0f, n, r) * 0.5f + n * 0.5f + t

}
fun  regularEaseOut(de: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
var e=de
e /= r
return (- n * de * (e - 2) + t)/100
}
fun regularEaseIn(de: Float, t: Float=0f, n: Float=100f, r: Float=100f):Float {
var e=de
e /= r
return (n * e * de + t)/100
}

fun elasticIn(dt: Float): Float {
if(dt>99){return 100f}
var t=dt
t /= 100
if (t == 0f || t == 1f) return t
val pi2 = Math.PI * 2
val s = .3 / pi2 * Math.asin(1.0)
val o = t - 1f
return -(1 * Math.pow(2.0, 10.0 * o) * Math.sin((o - s) * pi2 / .3)).toFloat()*100
}
fun elasticOut(dt: Float): Float {
if(dt>99){return 100f}
var t=dt
t /= 100
if (t == 0f || t == 1f) return t
val pi2 = Math.PI * 2
val s = .3 / pi2 * Math.asin(1.0)
return (Math.pow(2.0, (-10 * t).toDouble()) * Math.sin((t - s) * pi2 / .3) + 1).toFloat()*100

}
fun elasticEaseInOut(dt:Float, e:Float=0f, n:Float=100f, r:Float=100f):Float {
if(dt>99){return 100f}
var t=dt
t /= r
val pi2 = Math.PI * 2
val s = .45 / pi2 * Math.asin(1.0)
var o = t * 2f
return if (o < 1) {
o -= 1f
(-0.5f * (Math.pow(2.0, (10 * o).toDouble()) * Math.sin((o - s) * pi2 / .45))).toFloat()*100
} else {
o -= 1f
(Math.pow(2.0, (-10 * o).toDouble()) * Math.sin((o - s) * pi2 / .45) * 0.5 + 1).toFloat()*100
}
}
fun bounceEaseInOut(e:Float, t:Float=0f, n:Float=100f, r:Float=100f):Float {
if (e < r / 2) return bounceEaseIn(e * 2f, 0f, n, r) * 0.5f + t;
else return bounceEaseOut(e * 2f - r, 0f, n, r) * 0.5f + n * 0.5f + t
}
fun bounceEaseIn(e:Float, t:Float=0f, n:Float=100f, r:Float=100f):Float {
return n - bounceEaseOut(r - e, 0f, n, r) + t
}
fun bounceEaseOut(dt:Float, b:Float=0f, c:Float=100f, d:Float=100f):Float {
var t=dt
t /= d
if (t < (1/2.75f)) {
return c*(7.5625f*t*t) + b
} else if (t < (2/2.75f)) {
var dt=t-(1.5f/2.75f)
return c*(7.5625f*(dt)*dt + .75f) + b
} else if (t < (2.5/2.75)) {
var dt=t-(2.25f/2.75f)
return c*(7.5625f*(dt)*dt + .9375f) + b
} else {
var dt=t-(2.625f/2.75f)
return c*(7.5625f*(dt)*dt + .984375f) + b
}
}``````

feel free to change it on your needs.##all functions are called by

``function(Float 0..100)``

Don’t have to pass the other arguments

2 Likes