@name delta_time_test
@inputs 
@outputs [Duration Step Progress Frac]
@persist [TimeC TimeD TimeP TimeF] [Duration Step Progress Frac]
@trigger none

interval(60)

if (!TimeP) { 
    TimeP = curtime()
    
    function number linear( Y0, Y1, T ) {
        return Y0 + T * (Y1 - Y0)
    }

    function number cosine( Y0, Y1, T ) {
        return linear( Y0, Y1, -cosr( pi() * T ) / 2 + 0.5 )
    }
    
    function number accelerate( Y0, Y1, T ) {
        return linear( Y0, Y1, T^2 )
    }
    
    function number decelerate( Y0, Y1, T ) {
        return linear( Y0, Y1, 1 - ( 1 - T )^2 )
    }    
    
    holoCreate(1) 
}

TimeC = curtime()          #current time
TimeD = TimeC - TimeP      #delta time
TimeP = TimeC              #last update time
TimeF += TimeD             #total incremented time

Duration = 5               #total desired duration
Factor   = 1               #speed up or slow down

Step     = TimeD*Factor
Progress = min(Progress + Step, Duration)
Frac     = cosine(0, 1, Progress/Duration)

if (changed(Progress) & Progress == Duration) {
    print( "Finished!\n" + TimeF + "\n" + Frac )  
}

holoPos(1, entity():pos() + bezier(vec(100,0,0), vec(50,0,200), vec(-100,0,0), Frac))
#holoPos(1, entity():pos() + mix( vec(100, 0, 0), vec(-100, 30, 0), Frac ))
