Compare commits

...

5 Commits

Author SHA1 Message Date
jill 8c0b2d3653 let the user control the graph time 2021-09-18 02:31:20 +03:00
jill 34fdd83ab3 dropdown open animation 2021-09-18 02:26:40 +03:00
jill ed5f93104d change mixpoint visual 2021-09-18 02:15:31 +03:00
jill 64850adae2 update conf.lua 2021-09-18 02:09:26 +03:00
jill de00c3a828 slightly different dropdown visual 2021-09-18 02:06:31 +03:00
4 changed files with 54 additions and 11 deletions

View File

@ -1,5 +1,18 @@
function love.conf(t)
t.identity = 'box-of-eases'
t.version = '11.3'
t.window.resizable = true
t.window.title = 'Box of Eases'
t.window.icon = 'logo.png'
t.window.msaa = 5
t.modules.audio = false
t.modules.data = false
t.modules.joystick = false
t.modules.math = false
t.modules.physics = false
t.modules.sound = false
t.modules.thread = false
t.modules.video = false
end

View File

@ -48,6 +48,7 @@ local function insertDropdown(tab, f)
dropdownId = dropdownId + 1
f.selected = (self.kget(f.name) or dropdownValueCache[f.name] or {selected = 1}).selected
f.selected = (f.selected - 1) % #f.options + 1
f.open = (self.kget(f.name) or {open = 0}).open
return table.insert(tab, f)
end
function self.createDropdowns()
@ -110,6 +111,14 @@ function self.update(dt)
dropdownScroll = math.min(dropdownScroll, 0)
dropdownScrollE = mix(dropdownScrollE, dropdownScroll, dt * 10)
end
for i, v in ipairs(dropdowns) do
if i == self.openDropdown then
v.open = mix(v.open, 1, dt * 14)
else
v.open = mix(v.open, 0, dt * 20)
end
end
end
function self.render()
@ -127,21 +136,21 @@ function self.render()
love.graphics.rectangle('line', x, y, w, h)
love.graphics.print(self.selected(i), x + margin/2, y + margin/2)
love.graphics.rectangle('line', x + w - h, y, h, h)
-- love.graphics.rectangle('line', x + w - h, y, h, h)
love.graphics.polygon('line', x + w - h/2 + 0.3 * h, y + h/2 - 0.3 * h, x + w - h/2 - 0.3 * h, y + h/2 - 0.3 * h, x + w - h/2, y + h/2 + 0.3 * h)
if self.openDropdown == i then
if self.openDropdown == i or v.open > 0.01 then
for i,o in ipairs(v.options) do
local x, y, w, h = x, y + i * h, w, h
local x, y, w, h = x, y + ((i - 1) * v.open + 1) * h, w, h * v.open
y = y + dropdownScrollE * h
y = y + dropdownScrollE * h * v.open
local gi = y / h
if gi > (maxDropdown + 1) or gi < 1 then
goto continue
end
-- help
local a = (1 - math.min(math.max((1 - (maxDropdown - gi)) * (1 - (math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1))), 0), 1)) * math.max(math.min(gi - 1, 1), 0)
local a = (1 - math.min(math.max((1 - (maxDropdown - gi)) * (1 - (math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1))), 0), 1)) * math.max(math.min(gi - 1, 1), 0) * v.open
love.graphics.setColor(0.06, 0.06, 0.12, 0.3 * a)
if mx > x and mx < x + w and my > y and my < y + h then
@ -165,8 +174,8 @@ function self.render()
local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1)
local size = margin
love.graphics.setColor(1, 1, 1, 0.9)
love.graphics.rectangle('fill', x + w - size, y + h + scroll * (1 - displayed) * (maxDropdown - 1) * h, size, displayed * (maxDropdown - 1) * h)
love.graphics.setColor(1, 1, 1, 0.9 * v.open)
love.graphics.rectangle('fill', x + w - size, y + h + scroll * (1 - displayed) * (maxDropdown - 1) * h * v.open, size, displayed * (maxDropdown - 1) * h * v.open)
end
end
end

View File

@ -3,6 +3,10 @@ local self = {}
local quality = 256
local graph = {}
self.touchtimer = 0
local timer = 0
function self.update(dt)
for i = 1, quality do
local a = (i - 1) / (quality - 1)
@ -18,6 +22,22 @@ function self.update(dt)
end
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()
@ -43,12 +63,12 @@ function self.render()
-- mixease point
if mode == 2 then
love.graphics.setColor(1, 1, 1, 0.8)
love.graphics.line(x + margin + mixpoint * w, y, x + margin + mixpoint * w, y + h)
love.graphics.setColor(1, 1, 1, 0.2 + self.touchtimer * 0.6)
love.graphics.line(x + margin + oldmixpoint * w, y, x + margin + oldmixpoint * w, y + h)
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)
@ -81,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

View File

@ -94,6 +94,7 @@ function love.draw()
if mx > x and mx < x + w and my > y and my < y + h and love.mouse.isDown(1) and dropdown.openDropdown == 0 then
mixpoint = (mx - x) / w
graph.touchtimer = 1
dropdown.createDropdowns()
end
end