From 56f3ba6faee95e1cee4762144410e0f829827c3a Mon Sep 17 00:00:00 2001 From: jill Date: Sat, 18 Sep 2021 13:02:25 +0300 Subject: [PATCH] icons --- dropdown.lua | 49 ++++++++++++++++++----- ease.lua | 3 +- easelib.lua | 88 ++++++++++++++++++++--------------------- inease-icon.png | Bin 0 -> 166 bytes inoutease-icon.png | Bin 0 -> 196 bytes instantease-icon.png | Bin 0 -> 132 bytes linearease-icon.png | Bin 0 -> 175 bytes main.lua | 2 + outease-icon.png | Bin 0 -> 177 bytes transientease-icon.png | Bin 0 -> 159 bytes unknownease-icon.png | Bin 0 -> 209 bytes 11 files changed, 88 insertions(+), 54 deletions(-) create mode 100644 inease-icon.png create mode 100644 inoutease-icon.png create mode 100644 instantease-icon.png create mode 100644 linearease-icon.png create mode 100644 outease-icon.png create mode 100644 transientease-icon.png create mode 100644 unknownease-icon.png diff --git a/dropdown.lua b/dropdown.lua index 1aaf554..eb47bcd 100644 --- a/dropdown.lua +++ b/dropdown.lua @@ -1,5 +1,15 @@ local self = {} +local icon = { + inease = love.graphics.newImage('inease-icon.png'), + outease = love.graphics.newImage('outease-icon.png'), + inoutease = love.graphics.newImage('inoutease-icon.png'), + transientease = love.graphics.newImage('transientease-icon.png'), + unknownease = love.graphics.newImage('unknownease-icon.png'), + linearease = love.graphics.newImage('linearease-icon.png'), + instantease = love.graphics.newImage('instantease-icon.png'), +} + local dropdowns = {} local dropdownValueCache = {} @@ -20,6 +30,14 @@ local function skeys(t) return k2 end +local function icons(keys) + local e = {} + for i,v in ipairs(keys) do + table.insert(e, (ease.eases[v].type or 'unknown') .. 'ease') + end + return e +end + function self.get(index) return dropdowns[index] end @@ -70,13 +88,16 @@ function self.createDropdowns() local param1 = {} local param2 = {} + local eases = skeys(ease.eases) + if d[dropdownId].selected == 1 then -- preview ease insertDropdown(d, { x = outerpadding + dropdownWidth + padding, y = outerpadding, width = dropdownWidth, - options = skeys(ease.eases), - name = 'ease1' + options = eases, + name = 'ease1', + icons = icons(eases) }) local _e = ease.eases[d[dropdownId].options[d[dropdownId].selected]] param1[1] = slider.kvalue(_e.name .. 'param11') or (_e.params[1] and _e.params[1].default) or 1 @@ -89,15 +110,17 @@ function self.createDropdowns() x = outerpadding + dropdownWidth + padding, y = outerpadding, width = dropdownWidth, - options = skeys(ease.eases), - name = 'ease1' + options = eases, + name = 'ease1', + icons = icons(eases) }) insertDropdown(d, { x = outerpadding + dropdownWidth + padding + dropdownWidth + padding, y = outerpadding, width = dropdownWidth, - options = skeys(ease.eases), - name = 'ease2' + options = eases, + name = 'ease2', + icons = icons(eases) }) local _e1 = ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].selected]] @@ -112,8 +135,9 @@ function self.createDropdowns() x = outerpadding + dropdownWidth + padding, y = outerpadding, width = dropdownWidth, - options = skeys(ease.eases), - name = 'ease1' + options = eases, + name = 'ease1', + icons = icons(eases) }) end @@ -182,7 +206,14 @@ function self.render() if i == v.selected then love.graphics.setColor(0.8, 0.8, 1, 1 * a) end - love.graphics.print(v.options[i], x + 2, y + 2) + + if v.icons and v.icons[i] then + local sprite = icon[v.icons[i]] + love.graphics.draw(sprite, x + 2, y + 2, 0, fontHeight / sprite:getWidth(), fontHeight / sprite:getHeight()) + love.graphics.print(v.options[i], x + 2 + fontHeight, y + 2) + else + love.graphics.print(v.options[i], x + 2, y + 2) + end ::continue:: end diff --git a/ease.lua b/ease.lua index 8a5fbce..793f8f5 100644 --- a/ease.lua +++ b/ease.lua @@ -37,7 +37,8 @@ for i,v in pairs(easelib) do min = min, i = i, name = v[1], - params = params + params = params, + type = v.type } end diff --git a/easelib.lua b/easelib.lua index 65345c9..559ef62 100644 --- a/easelib.lua +++ b/easelib.lua @@ -19,52 +19,52 @@ self = setmetatable(self, { end }) -table.insert(self, {'linear', function(t) return t end}) -table.insert(self, {'instant', function() return 1 end}) +table.insert(self, {'linear', function(t) return t end, type = 'linear'}) +table.insert(self, {'instant', function() return 1 end, type = 'instant'}) -table.insert(self, {'bounce', function(t) return 4 * t * (1 - t) end}) -table.insert(self, {'tri', function(t) return 1 - abs(2 * t - 1) end}) -table.insert(self, {'bell', function(t) return self.inOutQuint(self.tri(t)) end}) -table.insert(self, {'pop', function(t) return 3.5 * (1 - t) * (1 - t) * sqrt(t) end}) -table.insert(self, {'tap', function(t) return 3.5 * t * t * sqrt(1 - t) end}) -table.insert(self, {'pulse', function(t) return t < .5 and self.tap(t * 2) or -self.pop(t * 2 - 1) end}) +table.insert(self, {'bounce', function(t) return 4 * t * (1 - t) end, type = 'transient'}) +table.insert(self, {'tri', function(t) return 1 - abs(2 * t - 1) end, type = 'transient'}) +table.insert(self, {'bell', function(t) return self.inOutQuint(self.tri(t)) end, type = 'transient'}) +table.insert(self, {'pop', function(t) return 3.5 * (1 - t) * (1 - t) * sqrt(t) end, type = 'transient'}) +table.insert(self, {'tap', function(t) return 3.5 * t * t * sqrt(1 - t) end, type = 'transient'}) +table.insert(self, {'pulse', function(t) return t < .5 and self.tap(t * 2) or -self.pop(t * 2 - 1) end, type = 'transient'}) -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, {'spike', function(t) return exp(-10 * abs(2 * t - 1)) end, type = 'transient'}) +table.insert(self, {'inverse', function(t) return t * t * (1 - t) * (1 - t) / (0.5 - t) end, type = 'transient'}) 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'}}) +end, {1, 10, 1.4, 'damp'}, {1, 25, 6, 'count'}, type = 'transient'}) 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'}}) +end, {1, 10, 1.4, 'damp'}, {1, 25, 6, 'count'}, type = 'transient'}) 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'}}) +end, {1, 10, 1.4, 'damp'}, {1, 25, 6, 'count'}, type = 'transient'}) table.insert(self, {'impulse', function(t, damp) t = t ^ damp return t * (1000 ^ -t - 0.001) * 18.6 -end, {0, 10, 0.9, 'damp'}}) +end, {0, 10, 0.9, 'damp'}, type = 'transient'}) table.insert(self, {'inSine', function(x) return 1 - cos(x * (pi * 0.5)) -end}) +end, type = 'in'}) table.insert(self, {'outSine', function(x) return sin(x * (pi * 0.5)) -end}) +end, type = 'out'}) table.insert(self, {'inOutSine', function(x) return 0.5 - 0.5 * cos(x * pi) -end}) +end, type = 'inout'}) -table.insert(self, {'inQuad', function(t) return t * t end}) -table.insert(self, {'outQuad', function(t) return -t * (t - 2) end}) +table.insert(self, {'inQuad', function(t) return t * t end, type = 'in'}) +table.insert(self, {'outQuad', function(t) return -t * (t - 2) end, type = 'out'}) table.insert(self, {'inOutQuad', function(t) t = t * 2 if t < 1 then @@ -72,9 +72,9 @@ table.insert(self, {'inOutQuad', function(t) else return 1 - 0.5 * (2 - t) ^ 2 end -end}) -table.insert(self, {'inCubic', function(t) return t * t * t end}) -table.insert(self, {'outCubic', function(t) return 1 - (1 - t) ^ 3 end}) +end, type = 'inout'}) +table.insert(self, {'inCubic', function(t) return t * t * t end, type = 'in'}) +table.insert(self, {'outCubic', function(t) return 1 - (1 - t) ^ 3 end, type = 'out'}) table.insert(self, {'inOutCubic', function(t) t = t * 2 if t < 1 then @@ -82,9 +82,9 @@ table.insert(self, {'inOutCubic', function(t) else return 1 - 0.5 * (2 - t) ^ 3 end -end}) -table.insert(self, {'inQuart', function(t) return t * t * t * t end}) -table.insert(self, {'outQuart', function(t) return 1 - (1 - t) ^ 4 end}) +end, type = 'inout'}) +table.insert(self, {'inQuart', function(t) return t * t * t * t end, type = 'in'}) +table.insert(self, {'outQuart', function(t) return 1 - (1 - t) ^ 4 end, type = 'out'}) table.insert(self, {'inOutQuart', function(t) t = t * 2 if t < 1 then @@ -92,9 +92,9 @@ table.insert(self, {'inOutQuart', function(t) else return 1 - 0.5 * (2 - t) ^ 4 end -end}) -table.insert(self, {'inQuint', function(t) return t ^ 5 end}) -table.insert(self, {'outQuint', function(t) return 1 - (1 - t) ^ 5 end}) +end, type = 'inout'}) +table.insert(self, {'inQuint', function(t) return t ^ 5 end, type = 'in'}) +table.insert(self, {'outQuint', function(t) return 1 - (1 - t) ^ 5 end, type = 'out'}) table.insert(self, {'inOutQuint', function(t) t = t * 2 if t < 1 then @@ -102,9 +102,9 @@ table.insert(self, {'inOutQuint', function(t) else return 1 - 0.5 * (2 - t) ^ 5 end -end}) -table.insert(self, {'inExpo', function(t) return 1000 ^ (t - 1) - 0.001 end}) -table.insert(self, {'outExpo', function(t) return 1.001 - 1000 ^ -t end}) +end, type = 'inout'}) +table.insert(self, {'inExpo', function(t) return 1000 ^ (t - 1) - 0.001 end, type = 'in'}) +table.insert(self, {'outExpo', function(t) return 1.001 - 1000 ^ -t end, type = 'out'}) table.insert(self, {'inOutExpo', function(t) t = t * 2 if t < 1 then @@ -112,9 +112,9 @@ table.insert(self, {'inOutExpo', function(t) else return 1.0005 - 0.5 * 1000 ^ (1 - t) end -end}) -table.insert(self, {'inCirc', function(t) return 1 - sqrt(1 - t * t) end}) -table.insert(self, {'outCirc', function(t) return sqrt(-t * t + 2 * t) end}) +end, type = 'inout'}) +table.insert(self, {'inCirc', function(t) return 1 - sqrt(1 - t * t) end, type = 'in'}) +table.insert(self, {'outCirc', function(t) return sqrt(-t * t + 2 * t) end, type = 'out'}) table.insert(self, {'inOutCirc', function(t) t = t * 2 if t < 1 then @@ -123,9 +123,9 @@ table.insert(self, {'inOutCirc', function(t) t = t - 2 return 0.5 + 0.5 * sqrt(1 - t * t) end -end}) +end, type = 'inout'}) -table.insert(self, {'inBounce', function(t) return 1 - self.outBounce(1 - t) end}) +table.insert(self, {'inBounce', function(t) return 1 - self.outBounce(1 - t) end, type = 'in'}) table.insert(self, {'outBounce', function(t) if t < 1 / 2.75 then return 7.5625 * t * t @@ -139,37 +139,37 @@ table.insert(self, {'outBounce', function(t) t = t - 2.625 / 2.75 return 7.5625 * t * t + 0.984375 end -end}) +end, type = 'out'}) table.insert(self, {'inOutBounce', function(t) if t < 0.5 then return self.inBounce(t * 2) * 0.5 else return self.outBounce(t * 2 - 1) * 0.5 + 0.5 end -end}) +end, type = 'inout'}) table.insert(self, {'inElastic', function(t, a, p) return 1 - self.outElastic(1 - t, a, p) -end, {1, 3, 1, 'a'}, {0, 2, 0.3, 'p'}, overridemin = true}) +end, {1, 3, 1, 'a'}, {0, 2, 0.3, 'p'}, overridemin = true, type = 'in'}) table.insert(self, {'outElastic', function(t, a, p) return a * pow(2, -10 * t) * sin((t - p / (2 * pi) * asin(1/a)) * 2 * pi / p) + 1 -end, {1, 3, 1, 'a'}, {0, 2, 0.3, 'p'}, overridemin = true}) +end, {1, 3, 1, 'a'}, {0, 2, 0.3, 'p'}, overridemin = true, type = 'out'}) table.insert(self, {'inOutElastic', function(t, a, p) return t < 0.5 and 0.5 * self.inElastic(t * 2, 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}) +end, {1, 3, 1, 'a'}, {0, 2, 0.3, 'p'}, overridemin = true, type = 'inout'}) table.insert(self, {'inBack', function(t, a) return t * t * (a * t + t - a) -end, {0, 3, 1.70158, 'a'}, overridemin = true}) +end, {0, 3, 1.70158, 'a'}, overridemin = true, type = 'in'}) table.insert(self, {'outBack', function(t, a) t = t - 1 return t * t * ((a + 1) * t + a) + 1 -end, {0, 3, 1.70158, 'a'}, overridemin = true}) +end, {0, 3, 1.70158, 'a'}, overridemin = true, type = 'out'}) 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'}, overridemin = true}) +end, {0, 3, 1.70158, 'a'}, overridemin = true, type = 'inout'}) return self diff --git a/inease-icon.png b/inease-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e559a142c453056f25cf738b46c56b44e0f36150 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|5jns$vjX=;D)U9d8z~}Li>CDfNLdL&)8{X9X+Rbpcj136Hl6cxP zeWu?#;IW1A#J0rC9akBWOcj~k*w`+8X5^W%YLkMF;&p*8Muz9Ux`q6+f2;!9#o+1c K=d#Wzp$P!UGdV~A literal 0 HcmV?d00001 diff --git a/inoutease-icon.png b/inoutease-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..24834794a238c1cd22f016ee938ae5d7904798ae GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|>O5T>Lo9le z6BdYB)c!tSpLF#ekN>}VW1FA$%s{}cIqiVS%Jp+jdu-xPn01j+SX1u+_lKPizN;J0 zDH7S;uz+#D{mj4VPpw-eGfD~%o>|UVk-NN$dxP4Nnf}cGj13G7mU!nM$hK}{T$0hk r=*Gr&=@X-oL1?ODgv&Zb5oU&^(+w5ZE`GxUbP0o}tDnm{r-UW|E|5e) literal 0 HcmV?d00001 diff --git a/instantease-icon.png b/instantease-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7b733c34800f5876b61e651aa5ed6d8d5e0b729b GIT binary patch literal 132 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|>^xl@Lo9le z6BY;<9Fka`|Nm#cLZ0iSw6J}_JvuL#mh5Wi4B=hO)+6O0%q$@(q42Xo=IpXnIvq>= d*C~oHGc;=O&bslywg+eugQu&X%Q~loCIA>PC>a0% literal 0 HcmV?d00001 diff --git a/linearease-icon.png b/linearease-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5b4129636b0d5fc01c6eb65c93017b0e7802a724 GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|GCf@!Lo9mN zUf#{yV8G*gQJO_J+JNci{x-oIO1Tq!S{)|z%T|=WD-`{a{d!yX(^{T5hF#N=4J#y% z9W`bAeuKv*S$IO%RR_H=#-%&Bt~^p&(7Cz6%#Uf>57vle2KI0D1$py+y^hfSRLQRX X*Q(~<#+y5UmNIy{`njxgN@xNArEx!m literal 0 HcmV?d00001 diff --git a/main.lua b/main.lua index cc95a1a..244b954 100644 --- a/main.lua +++ b/main.lua @@ -3,6 +3,8 @@ for k, v in pairs(_G) do table.insert(default_G, k) end +love.graphics.setDefaultFilter('nearest', 'nearest') + ease = require 'ease' slider = require 'slider' diff --git a/outease-icon.png b/outease-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..32b6f232eb2e1b70dad8ed202f2af241b96d012d GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|vOQfKLo9le z6BY;<9Fka`|Nm$Hs#AwL{0*6znGc`+@Z`V2wqK`q_UIhB(X@^;l5ahuLGO!M8=5X} z|NqDRneuHf5eKsdk+VK3H=TO8JxZ;P>Md9&?!i}?wWA@4Swd36Kv-}igX;SU*&Ih1 Z7;e5dX!`A~I3H*&gQu&X%Q~loCIEqEK!gAQ literal 0 HcmV?d00001 diff --git a/transientease-icon.png b/transientease-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..2e2c61fb9199ce7cdedf1da584c72eacb3a7c87b GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|B0XIkLo9le z6BdYB)c!tSpY!PC=Kufw=lzvmEyD~1!oIN$ImUY77tXQX$T_0sCN2JeyR^je)ozCQ zZ*Rmn#)=ChTkq1=C}UJUQ&wa$d(|d`LzYjZoD3Nl?(K7Q&D4|yS;FAy>gTe~DWM4f D)m=39 literal 0 HcmV?d00001 diff --git a/unknownease-icon.png b/unknownease-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..77a446adf494f4c77381b4052d7fc8b449907346 GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|x;