How to do an operation on a variable and assign it that new value for easing calculations?

Okay, maybe you guys can help me out a very last time with this

That’s my new function

fun bounceEaseOut(de:Float, t:Float=0f, n:Float=100f, r:Float=100f):Float {
    var e:Float=de
    if (e.div(r) < 1f / 2.75f) {
        println("A By VAL")
        return n * 7.5625f * e * e + t
    } else if (e < 2f / 2.75f) {
        println("B By VAL")
        return n * (7.5625f * e.minus(1.5f / 2.75f)  * e + 0.75f) + t
    } else if (e < 2.5f / 2.75f) {
        println("C By VAL")
        return n * (7.5625f * e.minus(2.25f / 2.75f)  * e + 0.9375f) + t
    } else {
        println("D By VAL")
        return n * (7.5625f * e.minus(2.625f / 2.75f) * e + 0.984375f) + t
    }
}

The working equvalent in Javascript is that

function bounceEaseOut(e, t, n, r) {
    if ((e /= r) < 1 / 2.75) {
        return n * 7.5625 * e * e + t
    } else if (e < 2 / 2.75) {
        return n * (7.5625 * (e -= 1.5 / 2.75) * e + 0.75) + t
    } else if (e < 2.5 / 2.75) {
        return n * (7.5625 * (e -= 2.25 / 2.75) * e + 0.9375) + t
    } else {
        return n * (7.5625 * (e -= 2.625 / 2.75) * e + 0.984375) + t
    }
}

when i call my new kotlin function by

var f:Float=0f
        for(i in (0..100)){
            println("Value  "+i.toFloat()+" "+bounceEaseOut(f))
            f+=1f
        }

it still refuses to do the right calculation

I should receive a number from 0 to 100. Instead i get Numbers from 0.0 to 7490411.0 and im at the end of my latin

Don’t know what else i should change

1 Like