Fixed bad behaviour in init
This commit is contained in:
parent
0e8a501049
commit
0a64b6e966
22
init.lua
22
init.lua
|
@ -117,15 +117,21 @@ function palette_swap.color_map.invert (r,g,b)
|
||||||
return 1 - r, 1 - g, 1 - b
|
return 1 - r, 1 - g, 1 - b
|
||||||
end
|
end
|
||||||
|
|
||||||
function palette_swap.color_map.switch_channel (mode)
|
local CHANNEL_ORDERS = {
|
||||||
local channels = {'r', 'g', 'b'}
|
[0] = {'r', 'g', 'b'},
|
||||||
local channel_order = {}
|
[1] = {'g', 'b', 'r'},
|
||||||
for i = 1, #channels do
|
[2] = {'b', 'r', 'g'},
|
||||||
local index = (mode % #channels) + 1
|
[3] = {'r', 'b', 'g'},
|
||||||
mode = mode / #channels
|
[4] = {'b', 'g', 'r'},
|
||||||
channel_order[#channel_order+1] = table.remove(channels,index)
|
[5] = {'g', 'r', 'b'},
|
||||||
end
|
[6] = {'b', 'g', 'r'},
|
||||||
|
[7] = {'b', 'g', 'r'}, -- TODO
|
||||||
|
[8] = {'b', 'g', 'r'}, -- TODO
|
||||||
|
[9] = {'r', 'g', 'b'}, -- TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
function palette_swap.color_map.switch_channel (mode)
|
||||||
|
local channel_order = CHANNEL_ORDERS[mode]
|
||||||
local func_s = ("return function (r, g, b) return %s, %s, %s end"):format(unpack(channel_order))
|
local func_s = ("return function (r, g, b) return %s, %s, %s end"):format(unpack(channel_order))
|
||||||
return loadstring (func_s)()
|
return loadstring (func_s)()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user