Merge pull request #3 from icrawler/Dev2

Stripped all trailing whitespace, changed ease function, and pre-computed po2
This commit is contained in:
rxi 2014-05-07 08:18:22 +01:00
commit 95c3f8960d
2 changed files with 14 additions and 13 deletions

View File

@ -38,7 +38,7 @@ lume.lerp(100, 200, .5) -- Returns 150
``` ```
### lume.smooth(a, b, amount) ### 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. interpolation.
### lume.pingpong(x) ### lume.pingpong(x)

View File

@ -59,7 +59,8 @@ end
function lume.smooth(a, b, amount) 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 return a + (b - a) * m
end end
@ -434,9 +435,9 @@ end
function lume.rgba(color) function lume.rgba(color)
local a = math_floor((color / 2 ^ 24) % 256) local a = math_floor((color / 16777216) % 256)
local r = math_floor((color / 2 ^ 16) % 256) local r = math_floor((color / 65536) % 256)
local g = math_floor((color / 2 ^ 08) % 256) local g = math_floor((color / 256) % 256)
local b = math_floor((color) % 256) local b = math_floor((color) % 256)
return r, g, b, a return r, g, b, a
end end