imgui = require "imgui"
WindowActive = imgui.ImBool()
function imgui.OnDrawFrame()
if WindowActive.v then
imgui.SetNextWindowSize(size_Animation_ChangeWindowSize, imgui.Cond.Always)
imgui.Begin("Test window", WindowActive)
if
imgui.Button("Change size")
then
th_Animation_ChangeWindowSize:run(imgui.GetWindowSize(), imgui.ImVec2(500, 500), 1000)
end
if
imgui.Button("Restore size")
then
size_Animation_ChangeWindowSize = imgui.ImVec2(200, 200)
end
imgui.End()
end
end
function main()
while not isSampAvailable() do wait(10) end
sampRegisterChatCommand("testimguianim", function(arg)
WindowActive.v = not WindowActive.v
end)
while true do wait(0) imgui.Process = WindowActive.v end
end
size_Animation_ChangeWindowSize = imgui.ImVec2(200, 200)
th_Animation_ChangeWindowSize = lua_thread.create_suspended(function(from, to, period)
period = period / 10
local xChange, yChange = ((from.x - to.x) / period), ((from.y - to.y) / period)
local xLost, yLost = (to.x - from.x), (to.y - from.y)
size_Animation_ChangeWindowSize = from
while (xLost ~= 0) and (yLost ~= 0) do wait(0)
size_Animation_ChangeWindowSize = imgui.ImVec2(size_Animation_ChangeWindowSize.x - xChange, size_Animation_ChangeWindowSize.y - yChange)
xLost = xLost - math.abs(xChange)
yLost = yLost - math.abs(yChange)
if (xLost < 0.5 and xLost > -0.5) then xLost = 0 end
if (yLost < 0.5 and yLost > -0.5) then yLost = 0 end
end
size_Animation_ChangeWindowSize = imgui.ImVec2(round(size_Animation_ChangeWindowSize.x), round(size_Animation_ChangeWindowSize.y))
end)
function round(num)
if num >= 0 then return math.floor(num+.5)
else return math.ceil(num-.5) end
end