fixes + add the remaining eases

This commit is contained in:
jill 2021-09-18 04:20:46 +03:00
parent ca2bffeac8
commit 0edd69d87d
3 changed files with 59 additions and 7 deletions

View file

@ -68,10 +68,10 @@ function self.createDropdowns()
local param1 = {}
local param2 = {}
param1[1] = slider.kvalue('param11') or 1
param1[2] = slider.kvalue('param12') or 1
param2[1] = slider.kvalue('param21') or 1
param2[2] = slider.kvalue('param22') or 1
param1[1] = slider.kvalue('param11')
param1[2] = slider.kvalue('param12')
param2[1] = slider.kvalue('param21')
param2[2] = slider.kvalue('param22')
if d[dropdownId].selected == 1 then -- preview ease
insertDropdown(d, {
@ -81,9 +81,11 @@ function self.createDropdowns()
options = skeys(ease.eases),
name = 'ease1'
})
local _e = ease.eases[d[dropdownId].options[d[dropdownId].selected]].f
local _e = ease.eases[d[dropdownId].options[d[dropdownId].selected]]
param1[1] = param1[1] or (_e.params[1] and _e.params[1].default) or 1
param1[2] = param1[2] or (_e.params[2] and _e.params[2].default) or 1
ease.ease = function(x)
return _e(x, param1[1], param1[2])
return _e.f(x, param1[1], param1[2])
end
elseif d[dropdownId].selected == 2 then -- mix eases
insertDropdown(d, {
@ -100,7 +102,14 @@ function self.createDropdowns()
options = skeys(ease.eases),
name = 'ease2'
})
ease.ease = ease.mixEase(ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].selected]].f, ease.eases[d[dropdownId].options[d[dropdownId].selected]].f, slider.kvalue('mix'), param1, param2)
local _e1 = ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].selected]]
local _e2 = ease.eases[d[dropdownId].options[d[dropdownId].selected]]
param1[1] = param1[1] or (_e1.params[1] and _e1.params[1].default) or 1
param1[2] = param1[2] or (_e1.params[2] and _e1.params[2].default) or 1
param2[1] = param2[1] or (_e2.params[1] and _e2.params[1].default) or 1
param2[2] = param2[2] or (_e2.params[2] and _e2.params[2].default) or 1
ease.ease = ease.mixEase(_e1.f, _e2.f, slider.kvalue('mix'), param1, param2)
elseif d[dropdownId].selected == 3 then -- create eases
insertDropdown(d, {
x = outerpadding + dropdownWidth + padding,

View file

@ -32,6 +32,25 @@ table.insert(self, {'pulse', function(t) return t < .5 and self.tap(t * 2) or -s
table.insert(self, {'spike', function(t) return exp(-10 * abs(2 * t - 1)) end})
table.insert(self, {'inverse', function(t) return t * t * (1 - t) * (1 - t) / (0.5 - t) end})
table.insert(self, {'popElastic', function(t, damp, count)
return (1000 ^ -(t ^ damp) - 0.001) * sin(count * pi * t)
end, {1, 10, 1.4, 'damp'}, {1, 25, 6, 'count'}})
table.insert(self, {'tapElastic', function(t, damp, count)
return (1000 ^ -((1 - t) ^ damp) - 0.001) * sin(count * pi * (1 - t))
end, {1, 10, 1.4, 'damp'}, {1, 25, 6, 'count'}})
table.insert(self, {'pulseElastic', function(t, damp, count)
if t < .5 then
return self.tapElastic(t * 2, damp, count)
else
return -self.popElastic(t * 2 - 1, damp, count)
end
end, {1, 10, 1.4, 'damp'}, {1, 25, 6, 'count'}})
table.insert(self, {'impulse', function(t, damp)
t = t ^ damp
return t * (1000 ^ -t - 0.001) * 18.6
end, {0, 10, 0.9, 'damp'}})
table.insert(self, {'inSine', function(x)
return 1 - cos(x * (pi * 0.5))
end})
@ -141,4 +160,16 @@ table.insert(self, {'inOutElastic', function(t, a, p)
or 0.5 + 0.5 * self.outElastic(t * 2 - 1, a, p)
end, {1, 3, 1, 'a'}, {0, 2, 0.3, 'p'}, overridemin = true})
table.insert(self, {'inBack', function(t, a)
return t * t * (a * t + t - a)
end, {0, 3, 1.70158, 'a'}})
table.insert(self, {'outBack', function(t, a)
t = t - 1 return t * t * ((a + 1) * t + a) + 1
end, {0, 3, 1.70158, 'a'}})
table.insert(self, {'inOutBack', function(t, a)
return t < 0.5
and 0.5 * self.inBack(t * 2, a)
or 0.5 + 0.5 * self.outBack(t * 2 - 1, a)
end, {0, 3, 1.70158, 'a'}})
return self

View file

@ -115,6 +115,10 @@ function self.render()
local normalvalue = normalize(v.value, v.min, v.max)
local normaloldvalue = normalize(v.oldvalue, v.min, v.max)
local normaldefault = normalize(v.default, v.min, v.max)
love.graphics.setColor(0.7, 0.7, 0.7, 0.3)
love.graphics.line(x + normaldefault * w, y, x + normaldefault * w, y + h)
local sx, sy = x + w * normaloldvalue, y + h/2
local ssize = h * 0.5
@ -149,6 +153,14 @@ function self.render()
if v.name == 'mix' then graph.touchtimer = 1 end -- sorry !!!
createUI()
end
if mx > x and mx < x + w and my > y and my < y + h and love.mouse.isDown(2) and dropdown.openDropdown == 0 then
v.value = v.default
createUI()
end
if mx > x and mx < x + w and my > y and my < y + h and love.mouse.isDown(3) and dropdown.openDropdown == 0 then
v.value = v.min + math.random() * (v.max - v.min)
createUI()
end
end
end