let the user control the graph time

This commit is contained in:
jill 2021-09-18 02:31:20 +03:00
parent 34fdd83ab3
commit 8c0b2d3653

View file

@ -5,6 +5,8 @@ local graph = {}
self.touchtimer = 0
local timer = 0
function self.update(dt)
for i = 1, quality do
local a = (i - 1) / (quality - 1)
@ -21,6 +23,21 @@ function self.update(dt)
graph[i] = mix(v, b, math.min(dt * 18, 1))
end
self.touchtimer = mix(self.touchtimer, 0, dt * 2)
-- lots of math just for the timer
-- may need to abstract this out, somehow
-- todo
local sw, sh = love.graphics.getDimensions()
local csize = 10 -- preview point size
local size = math.min((sw - outerpadding) - ((dropdown.kget('ease2') or dropdown.kget('ease1')).x + dropdownWidth + padding), sh - outerpadding * 2 - padding * 3 - csize)
local x, y, w, h = sw - outerpadding - size, outerpadding, size, size
local mx, my = love.mouse.getPosition()
if not (love.mouse.isDown(1) and mx > x and mx < x + w and my > y and my < y + h) then
timer = (timer + dt) % 2
else
timer = mix(timer, (mx - x) / w, dt * 14)
end
end
function self.render()
@ -51,7 +68,7 @@ function self.render()
end
-- preview point
local t = love.timer.getTime() % 1
local t = timer % 1
love.graphics.setColor(0.4, 0.4, 1, 0.4)
love.graphics.line(x + margin + t * w, y, x + margin + t * w, y + h)
@ -84,7 +101,7 @@ function self.render()
local a1 = ease.ease(t)
local a2 = ease.ease(math.max(math.min(t - 0.1, 1), 0))
local da = a1
if love.timer.getTime() % 2 < 1 and math.floor(ease.ease(0) + 0.5) ~= math.floor(ease.ease(1) + 0.5) then
if timer % 2 > 1 and math.floor(ease.ease(0) + 0.5) ~= math.floor(ease.ease(1) + 0.5) then
da = 1 - da
end
if minEase then