feature/simple_ui #18

Merged
PeaAshMeter merged 25 commits from feature/simple_ui into main 2025-11-08 01:32:47 +03:00
Showing only changes of commit 99fe4c0556 - Show all commits

52
lib/utils/easing.lua Normal file
View File

@ -0,0 +1,52 @@
---- Функции смягчения, нормализованные к [0, 1]
---@alias ease fun(x: number): number
local easing = {}
--- @type ease
function easing.easeInSine(x)
return 1 - math.cos((x * math.pi) / 2);
end
--- @type ease
function easing.easeOutSine(x)
return math.sin((x * math.pi) / 2);
end
--- @type ease
function easing.easeInOutSine(x)
return -(math.cos(x * math.pi) - 1) / 2;
end
--- @type ease
function easing.easeInQuad(x)
return x * x
end
--- @type ease
function easing.easeOutQuad(x)
return 1 - (1 - x) * (1 - x)
end
--- @type ease
function easing.easeInOutQuad(x)
return x < 0.5 and 2 * x * x or 1 - math.pow(-2 * x + 2, 2) / 2;
end
--- @type ease
function easing.easeInCubic(x)
return x * x * x
end
--- @type ease
function easing.easeOutCubic(x)
return 1 - math.pow(1 - x, 3)
end
--- @type ease
function easing.easeInOutCubic(x)
return x < 0.5 and 4 * x * x * x or 1 - math.pow(-2 * x + 2, 3) / 2;
end
return easing