Make animation speed independent of config.fps, add config.animation_rate to fine-tune animation speed (#93)

* animation rate config field

* @franko's math magic to make it look more correct
This commit is contained in:
liquidev
2021-03-10 16:35:37 +01:00
committed by GitHub
parent 3af6af654b
commit 844ecd1f26
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -24,7 +24,10 @@ function View:move_towards(t, k, dest, rate)
if not config.transitions or math.abs(val - dest) < 0.5 then
t[k] = dest
else
t[k] = common.lerp(val, dest, rate or 0.5)
rate = common.clamp(rate or 0.5, 1e-8, 1 - 1e-8)
local alpha = math.log(1 - rate) * config.animation_rate
local dt = 60 / config.fps
t[k] = common.lerp(val, dest, 1 - math.exp(alpha * dt))
end
if val ~= dest then
core.redraw = true