local tweening do
tweening = { }
local native_GetTimescale = utils.get_vfunc('engine.dll', 'VEngineClient014', 91, 'float(__thiscall*)(void*)')
local function solve(easings_fn, prev, new, clock, duration)
local prev = easings_fn(clock, prev, new - prev, duration)
if type(prev) == 'number' then
if math.abs(new - prev) <= .01 then
return new
end
local fmod = prev % 1
if fmod < .001 then
return math.floor(prev)
end
if fmod > .999 then
return math.ceil(prev)
end
end
return prev
end
local mt = { } do
local function update(self, duration, target, easings_fn)
local value_type = type(self.value)
local target_type = type(target)
if target_type == 'boolean' then
target = target and 1 or 0
target_type = 'number'
end
assert(value_type == target_type, string.format('type mismatch, expected %s (received %s)', value_type, target_type))
if target ~= self.to then
self.clock = 0
self.from = self.value
self.to = target
end
local clock = globals.frametime / native_GetTimescale()
local duration = duration or .15
if self.clock == duration then
return target
end
if clock <= 0 and clock >= duration then
self.clock = 0
self.from = target
self.to = target
self.value = target
return target
end
self.clock = math.min(self.clock + clock, duration)
self.value = solve(easings_fn or self.easings, self.from, self.to, self.clock, duration)
return self.value
end
mt.__metatable = false
mt.__call = update
mt.__index = mt
end
function tweening.new(default, easings_fn)
if type(default) == 'boolean' then
default = default and 1 or 0
end
local this = { }
this.clock = 0
this.value = default or 0
this.easings = easings_fn or function(t, b, c, d)
return c * t / d + b
end
return setmetatable(this, mt)
end
end
local pct = tweening.new()
events.render(function()
pct(.5, some_boolean or value_to_scale) -- во второй аргумент можешь сувать либо бул, либо флоат/инт
render.circle_outline(pos, clr, radius, pct.value)
end)