Optimized function
No edit summary |
(Optimized function) |
||
| Line 7: | Line 7: | ||
local num = select("#", ...) / 3 | local num = select("#", ...) / 3 | ||
if perc | if perc >= 1 then | ||
local r, g, b = select(num-2, ...) | |||
return r, g, b | |||
elseif perc <= 0 then | |||
local r, g, b = ... | |||
return r, g, b | |||
end | |||
local segment, relperc = math.modf(perc*(num-1)) | local segment, relperc = math.modf(perc*(num-1)) | ||
local r1, g1, b1 | local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...) | ||
return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc | return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc | ||