Compare commits

...

7 commits

Author SHA1 Message Date
78dbca6c05 i think thats the last time im modifying copy to clipboard 2021-09-19 20:13:46 +03:00
8fc339ec63 fixed some impercision in copy to clipboard 2021-09-19 19:44:55 +03:00
e3ddf63823 revise param algorithm in buttons
makes copy to clipboard more compact, less unnecessary params
2021-09-19 19:38:48 +03:00
171e5e69f4 fix copy to clipboard button typo 2021-09-19 19:19:53 +03:00
7e303c86b7 add graph zoom 2021-09-19 19:18:32 +03:00
261d8d6846 tweak slider spin values 2021-09-19 15:26:05 +03:00
ebc5aa1729 fix mixease and preview point line positioning 2021-09-19 15:24:27 +03:00
4 changed files with 91 additions and 31 deletions

View file

@ -99,6 +99,7 @@ function love.wheelmoved(x, y)
if y == 0 then return end if y == 0 then return end
if dropdown.wheelmoved(x, y) then return end if dropdown.wheelmoved(x, y) then return end
graph.wheelmoved(x, y)
end end
function love.keypressed(key) function love.keypressed(key)

View file

@ -14,6 +14,14 @@ function self.kget(key)
end end
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 buttonId
local function insertButton(tab, f) local function insertButton(tab, f)
buttonId = buttonId + 1 buttonId = buttonId + 1
@ -41,51 +49,66 @@ function self.createButtons()
if mode == modes.preview then if mode == modes.preview then
local e = ease.eases[dropdown.kselected('ease1')] local e = ease.eases[dropdown.kselected('ease1')]
param1[1] = slider.kvalue(e.name .. 'param11') or (e.params[1] and e.params[1].default) or 1 param1[1] = slider.kvalue(e.name .. 'param11')
param1[2] = slider.kvalue(e.name .. 'param12') or (e.params[2] and e.params[2].default) or 1 param1[2] = slider.kvalue(e.name .. 'param12')
local p1 = '' 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 for i,v in ipairs(param1) do
v = math.floor(v * 100) / 100
p1 = p1 .. (i > 1 and (', ' .. v) or v) p1 = p1 .. (i > 1 and (', ' .. v) or v)
end end
end
s = e.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') s = e.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '')
elseif mode == modes.mix then elseif mode == modes.mix then
local e1 = ease.eases[dropdown.kselected('ease1')] local e1 = ease.eases[dropdown.kselected('ease1')]
local e2 = ease.eases[dropdown.kselected('ease2')] local e2 = ease.eases[dropdown.kselected('ease2')]
param1[1] = slider.kvalue(e1.name .. 'param11') or (e1.params[1] and e1.params[1].default) or 1 param1[1] = slider.kvalue(e1.name .. 'param11')
param1[2] = slider.kvalue(e1.name .. 'param12') or (e1.params[2] and e1.params[2].default) or 1 param1[2] = slider.kvalue(e1.name .. 'param12')
param2[1] = slider.kvalue(e2.name .. 'param21') or (e2.params[1] and e2.params[1].default) or 1 param2[1] = slider.kvalue(e2.name .. 'param11')
param2[2] = slider.kvalue(e2.name .. 'param22') or (e2.params[2] and e2.params[2].default) or 1 param2[2] = slider.kvalue(e2.name .. 'param12')
local p1 = '' 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 for i,v in ipairs(param1) do
v = math.floor(v * 100) / 100
p1 = p1 .. (i > 1 and (', ' .. v) or v) p1 = p1 .. (i > 1 and (', ' .. v) or v)
end end
end
local p2 = '' 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 for i,v in ipairs(param2) do
v = math.floor(v * 100) / 100
p2 = p2 .. (i > 1 and (', ' .. v) or v) p2 = p2 .. (i > 1 and (', ' .. v) or v)
end end
end
s = 'mixEase(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. ', ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. ', ' .. slider.kvalue('mix') .. ')' s = 'mixEase(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. ', ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. ', ' .. (math.floor(slider.kvalue('mix') * 100) / 100) .. ')'
elseif mode == modes.multiply then elseif mode == modes.multiply then
local e1 = ease.eases[dropdown.kselected('ease1')] local e1 = ease.eases[dropdown.kselected('ease1')]
local e2 = ease.eases[dropdown.kselected('ease2')] local e2 = ease.eases[dropdown.kselected('ease2')]
param1[1] = slider.kvalue(_e1.name .. 'param11') or (_e1.params[1] and _e1.params[1].default) or 1 param1[1] = slider.kvalue(e1.name .. 'param11')
param1[2] = slider.kvalue(_e1.name .. 'param12') or (_e1.params[2] and _e1.params[2].default) or 1 param1[2] = slider.kvalue(e1.name .. 'param12')
param2[1] = slider.kvalue(_e2.name .. 'param21') or (_e2.params[1] and _e2.params[1].default) or 1 param2[1] = slider.kvalue(e2.name .. 'param11')
param2[2] = slider.kvalue(_e2.name .. 'param22') or (_e2.params[2] and _e2.params[2].default) or 1 param2[2] = slider.kvalue(e2.name .. 'param12')
local p1 = '' 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 for i,v in ipairs(param1) do
v = math.floor(v * 100) / 100
p1 = p1 .. (i > 1 and (', ' .. v) or v) p1 = p1 .. (i > 1 and (', ' .. v) or v)
end end
end
local p2 = '' 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 for i,v in ipairs(param2) do
v = math.floor(v * 100) / 100
p2 = p2 .. (i > 1 and (', ' .. v) or v) p2 = p2 .. (i > 1 and (', ' .. v) or v)
end end
end
s = 'function(x) ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. '(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. '(x)) end' s = 'function(x) ' .. e2.name .. (p2 ~= '' and ('.params(' .. p2 .. ')') or '') .. '(' .. e1.name .. (p1 ~= '' and ('.params(' .. p1 .. ')') or '') .. '(x)) end'
end end

View file

@ -4,6 +4,9 @@ local quality = 256
local graph = {} local graph = {}
self.touchtimer = 0 self.touchtimer = 0
self.zoom = 1
local zoome = 1
local timer = 0 local timer = 0
@ -41,6 +44,8 @@ function self.update(dt)
else else
timer = mix(timer, (mx - x) / w, dt * 14) timer = mix(timer, (mx - x) / w, dt * 14)
end end
zoome = mix(zoome, self.zoom, dt * 6)
end end
function self.render() function self.render()
@ -67,13 +72,13 @@ function self.render()
-- mixease point -- mixease point
if mode == modes.mix and slider.kget('mix') then if mode == modes.mix and slider.kget('mix') then
love.graphics.setColor(1, 1, 1, 0.2 + self.touchtimer * 0.6) love.graphics.setColor(1, 1, 1, 0.2 + self.touchtimer * 0.6)
love.graphics.line(x + margin + slider.kvalue('mix') * w, y, x + margin + slider.kvalue('mix') * w, y + h) love.graphics.line(x + slider.kvalue('mix') * w, y, x + slider.kvalue('mix') * w, y + h)
end end
-- preview point -- preview point
local t = timer % 1 local t = timer % 1
love.graphics.setColor(0.4, 0.4, 1, 0.4) love.graphics.setColor(0.4, 0.4, 1, 0.4)
love.graphics.line(x + margin + t * w, y, x + margin + t * w, y + h) love.graphics.line(x + t * w, y, x + margin + t * (w - margin * 2), y + h)
-- y = 0 point -- y = 0 point
-- todo: this will break with eases that dont have the first point at y0 -- todo: this will break with eases that dont have the first point at y0
@ -84,10 +89,11 @@ function self.render()
-- polygone -- polygone
-- this isnt done with a polygon because else itd waste a Bunch of ram and i kinda, dont want to do that? -- 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) love.graphics.setColor(1, 1, 1, 1)
local last = graph[1] or 0 local last = (((graph[1] or 0) - 0.5) * zoome) + 0.5
for gx = 1, quality - 1 do for gx = 1, quality - 1 do
local a = gx/quality local a = gx/quality
local b = graph[gx + 1] or 0 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 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) local ox, oy = x + margin + (gx - 1) * ((w - margin)/quality), y + h - margin - last * (h - margin * 2)
if math.abs(b - last) < 1 then if math.abs(b - last) < 1 then
@ -96,14 +102,29 @@ function self.render()
last = b last = b
end 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 -- preview
love.graphics.setColor(1, 1, 1, 0.2) love.graphics.setColor(0.16, 0.16, 0.17, 1)
love.graphics.line(x + margin, y + h + padding * 2 + csize/2, x + w - margin, y + h + padding * 2 + csize/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) love.graphics.setColor(0.4, 0.4, 1, 1)
local a1 = ease.ease(t) local a1 = ease.ease(t)
local a2 = ease.ease(math.max(math.min(t - 0.1, 1), 0)) local a2 = ease.ease(math.max(math.min(t - 0.1, 1), 0))
local da = a1 local da = ((a1 - 0.5) * zoome) + 0.5
if timer % 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 da = 1 - da
end end
@ -115,4 +136,21 @@ function self.render()
end end
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 return self

View file

@ -83,8 +83,7 @@ function self.createSliders()
max = v.max, max = v.max,
default = v.default, default = v.default,
name = ease1.name .. 'param1' .. i, name = ease1.name .. 'param1' .. i,
displayname = 'Parameter ' .. v.name, displayname = 'Parameter ' .. v.name
snap = 0.001
}) })
end end
end end
@ -98,8 +97,7 @@ function self.createSliders()
max = v.max, max = v.max,
default = v.default, default = v.default,
name = ease2.name .. 'param2' .. i, name = ease2.name .. 'param2' .. i,
displayname = 'Parameter ' .. v.name, displayname = 'Parameter ' .. v.name
snap = 0.001
}) })
end end
end end
@ -113,7 +111,7 @@ end
function self.update(dt) function self.update(dt)
for i, v in ipairs(sliders) do 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 * 8, 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 * 12, 1))
v.oldvalue = mix(v.oldvalue, v.value, math.min(dt * 20, 1)) v.oldvalue = mix(v.oldvalue, v.value, math.min(dt * 20, 1))
if v.spintimer > 1 then if v.spintimer > 1 then