From 17b58ec63d7363bab1fca4b8fba0b80082d45029 Mon Sep 17 00:00:00 2001 From: Phoenix Enero Date: Tue, 6 May 2014 09:36:51 +0800 Subject: [PATCH 1/3] Stripped all trailing whitespace --- lume.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lume.lua b/lume.lua index 1d2f3a2..d1d1985 100644 --- a/lume.lua +++ b/lume.lua @@ -136,7 +136,7 @@ end function lume.map(t, fn) - local rtn = {} + local rtn = {} for k, v in pairs(t) do rtn[k] = fn(v) end return rtn end @@ -170,7 +170,7 @@ end function lume.set(t, retainkeys) local rtn = {} - for k, v in pairs(lume.invert(t)) do + for k, v in pairs(lume.invert(t)) do rtn[retainkeys and v or (#rtn + 1)] = k end return rtn @@ -253,7 +253,7 @@ function lume.fn(fn, ...) local args = {...} return function(...) local a = lume.merge(lume.clone(args), {...}) - return fn(unpack(a)) + return fn(unpack(a)) end end @@ -363,8 +363,8 @@ end function lume.format(str, vars) if not vars then return str end - local f = function(x) - return tostring(vars[x] or vars[tonumber(x)] or "{" .. x .. "}") + local f = function(x) + return tostring(vars[x] or vars[tonumber(x)] or "{" .. x .. "}") end return (str:gsub("{(.-)}", f)) end @@ -401,7 +401,7 @@ function lume.hotswap(modname) local oldglobal = lume.clone(_G) local updated = {} local function update(old, new) - if updated[old] then return end + if updated[old] then return end updated[old] = true local oldmt, newmt = getmetatable(old), getmetatable(new) if oldmt and newmt then update(oldmt, newmt) end @@ -421,7 +421,7 @@ function lume.hotswap(modname) local newmod = require(modname) if type(oldmod) == "table" then update(oldmod, newmod) end for k, v in pairs(oldglobal) do - if v ~= _G[k] and type(v) == "table" then + if v ~= _G[k] and type(v) == "table" then update(v, _G[k]) _G[k] = v end @@ -457,4 +457,4 @@ function lume.chain(value) end -return lume +return lume \ No newline at end of file From 1a82d308affc56a351784bcb6f0107ddf8db71e7 Mon Sep 17 00:00:00 2001 From: Phoenix Enero Date: Tue, 6 May 2014 09:39:53 +0800 Subject: [PATCH 2/3] Changed ease function from cosine to cubic --- README.md | 2 +- lume.lua | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26a8af4..2aec81a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ lume.lerp(100, 200, .5) -- Returns 150 ``` ### lume.smooth(a, b, amount) -Similar to `lume.lerp()` but uses cosine interpolation instead of linear +Similar to `lume.lerp()` but uses cubic interpolation instead of linear interpolation. ### lume.pingpong(x) diff --git a/lume.lua b/lume.lua index d1d1985..e70c1cd 100644 --- a/lume.lua +++ b/lume.lua @@ -59,7 +59,8 @@ end function lume.smooth(a, b, amount) - local m = (1 - math_cos(lume.clamp(amount, 0, 1) * math_pi)) / 2 + local t = lume.clamp(amount, 0, 1) + local m = t*t*(3-2*t) return a + (b - a) * m end From 6b73aaa8ad70e63f2fff70c52edfe892fb4aa164 Mon Sep 17 00:00:00 2001 From: Phoenix Enero Date: Tue, 6 May 2014 09:41:02 +0800 Subject: [PATCH 3/3] Pre-computed powers of two in lume.rgba --- lume.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lume.lua b/lume.lua index e70c1cd..83e6c5d 100644 --- a/lume.lua +++ b/lume.lua @@ -435,9 +435,9 @@ end function lume.rgba(color) - local a = math_floor((color / 2 ^ 24) % 256) - local r = math_floor((color / 2 ^ 16) % 256) - local g = math_floor((color / 2 ^ 08) % 256) + local a = math_floor((color / 16777216) % 256) + local r = math_floor((color / 65536) % 256) + local g = math_floor((color / 256) % 256) local b = math_floor((color) % 256) return r, g, b, a end