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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -19,6 +19,7 @@ config.line_limit = 80
config.max_symbols = 4000
config.max_project_files = 2000
config.transitions = true
config.animation_rate = 1.0
config.blink_period = 0.8
-- Disable plugin loading setting to false the config entry

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