To speak simple, I am trying to figure out how to apply easing to a loop delay.
for (i := 0; i < 114; i++) {
// do a task
time.Sleep(//delay before next job)
}
As you can read it, this is very basic. Let say I want to complete the whole loop in 3s (job completion time is negligeable, t <= us
). What is the proper method with Penner's Equations to calculate for each iteration the proper eased delay ?
So, with this function, to simulate an acceleration from zero-velocity, how should I use the t
parameter each iteration of the loop to create the proper delay to sleep for ?
func easeInQuad(t float64) {
return math.Pow(t, 2)
}
I would be very thankfull if you could help me about this. Equations has not been a problem so far, but how to use them with my use case instead.
My question could looks like this one at first : Applying easing to setTimeout delays, within a loop but this one does not take the total time of the loop in account.
However, I think it may be better to use equations rewritten to use only one parameter, in range [0,1] : https://gist.github.com/rezoner/713615dabedb59a15470
From my understanding, I have to calculate the abstract "percentage time elapsed", and somehow interpolate this value with an easing function.
This Node project seems to do just that : https://github.com/CharlotteGore/animation-timer, but again I can't figure out how to reproduce it.