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:
+4
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user