function AnimateLib.TemporaryOnHeartbeat(w,G,y,g)local function N(y)if G>y then G=G-y w(y)else local y=G G=0 w(y)end end local function n()return G>0 end return AnimateLib.ConditionalOnHeartbeat(N,n,y,g)end return AnimateLib
--[[ @brief Performs an operation on heartbeat for a set amount of time.
     @details This fills a common need for animating things smoothly, esp. GUIs. Expect things animated through this function to be smoother than things animated on a while loop.
     @param fn The callback function for each heartbeat step.
     @param lengthOfTime The length of time which we should continually call the callback.
     @param yield Whether this function should yield or return immediately.
--]]
function AnimateLib.TemporaryOnHeartbeat(fn, lengthOfTime, yield, callback)
	local function PerfectDT(dt)
		if lengthOfTime > dt then
			lengthOfTime = lengthOfTime - dt
			fn(dt)
		else
			local t = lengthOfTime
			lengthOfTime = 0
			fn(t)
		end
	end
	local function Condition()
		return lengthOfTime > 0
	end
	return AnimateLib.ConditionalOnHeartbeat(PerfectDT, Condition, yield, callback)
end

return AnimateLib
