Compare commits
No commits in common. "78dbca6c05bd99de38393cbf6e5ff086f6c4c944" and "e9dccb863d10874bc16a0aab10a14b40b6953318" have entirely different histories.
78dbca6c05
...
e9dccb863d
4 changed files with 31 additions and 91 deletions
1
main.lua
1
main.lua
|
@ -99,7 +99,6 @@ function love.wheelmoved(x, y)
|
|||
if y == 0 then return end
|
||||
|
||||
if dropdown.wheelmoved(x, y) then return end
|
||||
graph.wheelmoved(x, y)
|
||||
end
|
||||
|
||||
function love.keypressed(key)
|
||||
|
|
|
@ -14,14 +14,6 @@ function self.kget(key)
|
|||
end
|
||||
end
|
||||
|
||||
local function nillify(tab) -- dumb hack. turns `false` into `nil`
|
||||
local t = {}
|
||||
for i,v in ipairs(tab) do
|
||||
if v then table.insert(t, v) end
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local buttonId
|
||||
local function insertButton(tab, f)
|
||||
buttonId = buttonId + 1
|
||||
|
@ -49,15 +41,12 @@ function self.createButtons()
|
|||
if mode == modes.preview then
|
||||
local e = ease.eases[dropdown.kselected('ease1')]
|
||||
|
||||
param1[1] = slider.kvalue(e.name .. 'param11')
|
||||
param1[2] = slider.kvalue(e.name .. 'param12')
|
||||
param1[1] = slider.kvalue(e.name .. 'param11') or (e.params[1] and e.params[1].default) or 1
|
||||
param1[2] = slider.kvalue(e.name .. 'param12') or (e.params[2] and e.params[2].default) or 1
|
||||
|
||||
local p1 = ''
|
||||
if param1[1] ~= (e.params[1] and e.params[1].default) or param1[2] ~= (e.params[2] and e.params[2].default) then
|
||||
for i,v in ipairs(param1) do
|
||||
v = math.floor(v * 100) / 100
|
||||
p1 = p1 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
for i,v in ipairs(param1) do
|
||||
p1 = p1 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
|
||||
s = e.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '')
|
||||
|
@ -65,49 +54,37 @@ function self.createButtons()
|
|||
local e1 = ease.eases[dropdown.kselected('ease1')]
|
||||
local e2 = ease.eases[dropdown.kselected('ease2')]
|
||||
|
||||
param1[1] = slider.kvalue(e1.name .. 'param11')
|
||||
param1[2] = slider.kvalue(e1.name .. 'param12')
|
||||
param2[1] = slider.kvalue(e2.name .. 'param11')
|
||||
param2[2] = slider.kvalue(e2.name .. 'param12')
|
||||
param1[1] = slider.kvalue(e1.name .. 'param11') or (e1.params[1] and e1.params[1].default) or 1
|
||||
param1[2] = slider.kvalue(e1.name .. 'param12') or (e1.params[2] and e1.params[2].default) or 1
|
||||
param2[1] = slider.kvalue(e2.name .. 'param21') or (e2.params[1] and e2.params[1].default) or 1
|
||||
param2[2] = slider.kvalue(e2.name .. 'param22') or (e2.params[2] and e2.params[2].default) or 1
|
||||
|
||||
local p1 = ''
|
||||
if param1[1] ~= (e1.params[1] and e1.params[1].default) or param1[2] ~= (e1.params[2] and e1.params[2].default) then
|
||||
for i,v in ipairs(param1) do
|
||||
v = math.floor(v * 100) / 100
|
||||
p1 = p1 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
for i,v in ipairs(param1) do
|
||||
p1 = p1 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
local p2 = ''
|
||||
if param2[1] ~= (e2.params[1] and e2.params[1].default) or param2[2] ~= (e2.params[2] and e2.params[2].default) then
|
||||
for i,v in ipairs(param2) do
|
||||
v = math.floor(v * 100) / 100
|
||||
p2 = p2 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
for i,v in ipairs(param2) do
|
||||
p2 = p2 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
|
||||
s = 'mixEase(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. ', ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. ', ' .. (math.floor(slider.kvalue('mix') * 100) / 100) .. ')'
|
||||
s = 'mixEase(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. ', ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. ', ' .. slider.kvalue('mix') .. ')'
|
||||
elseif mode == modes.multiply then
|
||||
local e1 = ease.eases[dropdown.kselected('ease1')]
|
||||
local e2 = ease.eases[dropdown.kselected('ease2')]
|
||||
|
||||
param1[1] = slider.kvalue(e1.name .. 'param11')
|
||||
param1[2] = slider.kvalue(e1.name .. 'param12')
|
||||
param2[1] = slider.kvalue(e2.name .. 'param11')
|
||||
param2[2] = slider.kvalue(e2.name .. 'param12')
|
||||
param1[1] = slider.kvalue(_e1.name .. 'param11') or (_e1.params[1] and _e1.params[1].default) or 1
|
||||
param1[2] = slider.kvalue(_e1.name .. 'param12') or (_e1.params[2] and _e1.params[2].default) or 1
|
||||
param2[1] = slider.kvalue(_e2.name .. 'param21') or (_e2.params[1] and _e2.params[1].default) or 1
|
||||
param2[2] = slider.kvalue(_e2.name .. 'param22') or (_e2.params[2] and _e2.params[2].default) or 1
|
||||
|
||||
local p1 = ''
|
||||
if param1[1] ~= (e1.params[1] and e1.params[1].default) or param1[2] ~= (e1.params[2] and e1.params[2].default) then
|
||||
for i,v in ipairs(param1) do
|
||||
v = math.floor(v * 100) / 100
|
||||
p1 = p1 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
for i,v in ipairs(param1) do
|
||||
p1 = p1 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
local p2 = ''
|
||||
if param2[1] ~= (e2.params[1] and e2.params[1].default) or param2[2] ~= (e2.params[2] and e2.params[2].default) then
|
||||
for i,v in ipairs(param2) do
|
||||
v = math.floor(v * 100) / 100
|
||||
p2 = p2 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
for i,v in ipairs(param2) do
|
||||
p2 = p2 .. (i > 1 and (', ' .. v) or v)
|
||||
end
|
||||
|
||||
s = 'function(x) ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. '(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. '(x)) end'
|
||||
|
|
|
@ -4,9 +4,6 @@ local quality = 256
|
|||
local graph = {}
|
||||
|
||||
self.touchtimer = 0
|
||||
self.zoom = 1
|
||||
|
||||
local zoome = 1
|
||||
|
||||
local timer = 0
|
||||
|
||||
|
@ -44,8 +41,6 @@ function self.update(dt)
|
|||
else
|
||||
timer = mix(timer, (mx - x) / w, dt * 14)
|
||||
end
|
||||
|
||||
zoome = mix(zoome, self.zoom, dt * 6)
|
||||
end
|
||||
|
||||
function self.render()
|
||||
|
@ -72,13 +67,13 @@ function self.render()
|
|||
-- mixease point
|
||||
if mode == modes.mix and slider.kget('mix') then
|
||||
love.graphics.setColor(1, 1, 1, 0.2 + self.touchtimer * 0.6)
|
||||
love.graphics.line(x + slider.kvalue('mix') * w, y, x + slider.kvalue('mix') * w, y + h)
|
||||
love.graphics.line(x + margin + slider.kvalue('mix') * w, y, x + margin + slider.kvalue('mix') * w, y + h)
|
||||
end
|
||||
|
||||
-- preview point
|
||||
local t = timer % 1
|
||||
love.graphics.setColor(0.4, 0.4, 1, 0.4)
|
||||
love.graphics.line(x + t * w, y, x + margin + t * (w - margin * 2), y + h)
|
||||
love.graphics.line(x + margin + t * w, y, x + margin + t * w, y + h)
|
||||
|
||||
-- y = 0 point
|
||||
-- todo: this will break with eases that dont have the first point at y0
|
||||
|
@ -89,11 +84,10 @@ function self.render()
|
|||
-- polygone
|
||||
-- this isnt done with a polygon because else itd waste a Bunch of ram and i kinda, dont want to do that?
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
local last = (((graph[1] or 0) - 0.5) * zoome) + 0.5
|
||||
local last = graph[1] or 0
|
||||
for gx = 1, quality - 1 do
|
||||
local a = gx/quality
|
||||
local b = graph[gx + 1] or 0
|
||||
b = ((b - 0.5) * zoome) + 0.5
|
||||
local px, py = x + margin + gx * ((w - margin)/quality), y + h - margin - b * (h - margin * 2)
|
||||
local ox, oy = x + margin + (gx - 1) * ((w - margin)/quality), y + h - margin - last * (h - margin * 2)
|
||||
if math.abs(b - last) < 1 then
|
||||
|
@ -102,29 +96,14 @@ function self.render()
|
|||
last = b
|
||||
end
|
||||
|
||||
-- zoom lines
|
||||
local a = math.min(math.abs(zoome - 1) * 10, 1)
|
||||
if a > 0 then
|
||||
love.graphics.setColor(1, 1, 1, a * 0.2)
|
||||
local ytop = y + h/2 - h * zoome * 0.5
|
||||
local ybot = y + h/2 + h * zoome * 0.5
|
||||
love.graphics.line(x, ytop, x + w, ytop)
|
||||
love.graphics.line(x, ybot, x + w, ybot)
|
||||
love.graphics.setColor(1, 1, 1, a * 0.3)
|
||||
love.graphics.print('y=1', x, ytop)
|
||||
love.graphics.print('y=0', x, ybot)
|
||||
end
|
||||
|
||||
-- preview
|
||||
love.graphics.setColor(0.16, 0.16, 0.17, 1)
|
||||
love.graphics.setColor(1, 1, 1, 0.2)
|
||||
love.graphics.line(x + margin, y + h + padding * 2 + csize/2, x + w - margin, y + h + padding * 2 + csize/2)
|
||||
love.graphics.setColor(0.3, 0.3, 0.31, 1)
|
||||
love.graphics.line(x + margin + (w - margin * 2) * (1 - zoome) * 0.5, y + h + padding * 2 + csize/2, x + w - margin - (w - margin * 2) * (1 - zoome) * 0.5, y + h + padding * 2 + csize/2)
|
||||
|
||||
love.graphics.setColor(0.4, 0.4, 1, 1)
|
||||
local a1 = ease.ease(t)
|
||||
local a2 = ease.ease(math.max(math.min(t - 0.1, 1), 0))
|
||||
local da = ((a1 - 0.5) * zoome) + 0.5
|
||||
local da = a1
|
||||
if timer % 2 > 1 and math.floor(ease.ease(0) + 0.5) ~= math.floor(ease.ease(1) + 0.5) then
|
||||
da = 1 - da
|
||||
end
|
||||
|
@ -136,21 +115,4 @@ function self.render()
|
|||
end
|
||||
end
|
||||
|
||||
function self.wheelmoved(wx, wy)
|
||||
local mx, my = love.mouse.getPosition()
|
||||
|
||||
-- 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
|
||||
|
||||
if mx > x and mx < x + w and my > y and my < y + h then
|
||||
self.zoom = self.zoom - wy * 0.1
|
||||
self.zoom = math.min(self.zoom, 1)
|
||||
self.zoom = math.max(self.zoom, 0.1)
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
|
@ -83,7 +83,8 @@ function self.createSliders()
|
|||
max = v.max,
|
||||
default = v.default,
|
||||
name = ease1.name .. 'param1' .. i,
|
||||
displayname = 'Parameter ' .. v.name
|
||||
displayname = 'Parameter ' .. v.name,
|
||||
snap = 0.001
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -97,7 +98,8 @@ function self.createSliders()
|
|||
max = v.max,
|
||||
default = v.default,
|
||||
name = ease2.name .. 'param2' .. i,
|
||||
displayname = 'Parameter ' .. v.name
|
||||
displayname = 'Parameter ' .. v.name,
|
||||
snap = 0.001
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -111,7 +113,7 @@ end
|
|||
|
||||
function self.update(dt)
|
||||
for i, v in ipairs(sliders) do
|
||||
v.spintimer = mix(v.spintimer + math.abs(normalize(v.value, v.min, v.max) - normalize(v.oldvalue, v.min, v.max)) * dt * 40, 0, math.min(dt * 12, 1))
|
||||
v.spintimer = mix(v.spintimer + math.abs(normalize(v.value, v.min, v.max) - normalize(v.oldvalue, v.min, v.max)) * dt * 40, 0, math.min(dt * 8, 1))
|
||||
v.oldvalue = mix(v.oldvalue, v.value, math.min(dt * 20, 1))
|
||||
|
||||
if v.spintimer > 1 then
|
||||
|
|
Loading…
Reference in a new issue