Last active
April 9, 2025 22:45
-
-
Save mvrozanti/5c99fd1d51a1b7f3381954021ebc8671 to your computer and use it in GitHub Desktop.
Revisions
-
mvrozanti revised this gist
Apr 9, 2025 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -178,7 +178,11 @@ function lightUpKey(keyName, level, maxLevel) local color = interpolate(startColor, endColor, percentage) local key = getKeyFromName(keyName) if key then if level == 0 then buffer[key] = fade(1, color, tocolor("black")) else buffer[key] = fade(fadeTime*(level+2)/11, color, tocolor("black")) end end end -
mvrozanti revised this gist
Aug 3, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -178,7 +178,7 @@ function lightUpKey(keyName, level, maxLevel) local color = interpolate(startColor, endColor, percentage) local key = getKeyFromName(keyName) if key then buffer[key] = fade(fadeTime*(level+1)/10, color, tocolor("black")) end end -
mvrozanti revised this gist
Jul 30, 2024 . No changes.There are no files selected for viewing
-
mvrozanti revised this gist
Jul 29, 2024 . 1 changed file with 18 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -87,7 +87,6 @@ graph = { ["FN"] = {"RALT", "DOT", "SLASH", "RSHIFT", "COMPOSE"}, ["RALT"] = {"SPACE", "COMMA", "DOT", "FN", "SLASH"}, ["INSERT"] = {"BACKSPACE", "BACKSLASH", "F12", "SYSRQ", "DELETE", "HOME", "END", "SCROLLLOCK"} } keys = keyleds.db @@ -98,6 +97,8 @@ delay = tonumber(keyleds.config.delay) or 0.05 startColor = tocolor(keyleds.config.startColor) or tocolor(1, 0, 0) endColor = tocolor(keyleds.config.endColor) or tocolor(0, 1, 1) fadeTime = tonumber(keyleds.config.fadeTime) or 1 startSpeed = tonumber(keyleds.config.startSpeed) or 10 endSpeed = tonumber(keyleds.config.endSpeed) or 0.01 if type(keys) ~= "table" then local tempKeys = {} @@ -109,6 +110,7 @@ end function init() buffer = RenderTarget:new() buffer:fill(tocolor('black')) end function onKeyEvent(key, isPress) @@ -127,7 +129,7 @@ function getKeyFromName(keyName) end function isVisited(visited, keyName) for i = 1, #visited do if visited[i] == keyName then return true end @@ -144,13 +146,19 @@ function lightUpKeys(keyName, level, maxLevel, visited) if #neighbors == 0 then return end lightUpKey(keyName, level, maxLevel) table.insert(visited, keyName) tries = 0 repeat local random_index = math.random(1, #neighbors) nextKey = neighbors[random_index] tries = tries + 1 until (not isVisited(visited, nextKey) or tries > 10) if nextKey == nil then return end for i = 1, numSplits do local speed = interpolateSpeed(startSpeed, endSpeed, level / maxLevel) wait(delay / speed) lightUpKeys(nextKey, level + 1, maxLevel, visited) end end @@ -161,6 +169,10 @@ function interpolate(color1, color2, percentage) return tocolor(red, green, blue) end function interpolateSpeed(startSpeed, endSpeed, percentage) return startSpeed * (1 - percentage) + endSpeed * percentage end function lightUpKey(keyName, level, maxLevel) local percentage = level / maxLevel local color = interpolate(startColor, endColor, percentage) -
mvrozanti revised this gist
Jul 11, 2024 . 1 changed file with 18 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,7 +70,7 @@ graph = { ["SLASH"] = {"DOT", "APOSTROPHE", "SEMICOLON", "RSHIFT"}, ["RSHIFT"] = {"SLASH", "RCTRL", "ENTER", "APOSTROPHE"}, ["RCTRL"] = {"RSHIFT", "COMPOSE", "LEFT"}, ["LEFT"] = {"RCTRL", "UP", "DOWN", "RIGHT", "RSHIFT"}, ["UP"] = {"END", "LEFT", "DOWN", "RIGHT"}, ["DOWN"] = {"LEFT", "UP", "RIGHT"}, ["RIGHT"] = {"UP", "DOWN", "LEFT"}, @@ -114,7 +114,7 @@ end function onKeyEvent(key, isPress) if not isPress then return end if graph[key.name] then thread(lightUpKeys, key.name, 0, numJumps, {}) end end @@ -126,19 +126,31 @@ function getKeyFromName(keyName) end end function isVisited(visited, keyName) for i = 1,#visited do if visited[i] == keyName then return true end end return false end function lightUpKeys(keyName, level, maxLevel, visited) if level >= maxLevel then return end local neighbors = graph[keyName] if neighbors == nil then print(keyName, '!!!') end if #neighbors == 0 then return end lightUpKey(keyName, level, maxLevel) table.insert(visited, keyName) repeat local random_index = math.random(1, #neighbors) nextKey = neighbors[random_index] until(not isVisited(visited, nextKey)) for i=1, numSplits do wait(delay) lightUpKeys(nextKey, level+1, maxLevel, visited) end end -
mvrozanti revised this gist
Jul 10, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -109,7 +109,6 @@ end function init() buffer = RenderTarget:new() end function onKeyEvent(key, isPress) -
mvrozanti revised this gist
Jun 25, 2024 . No changes.There are no files selected for viewing
-
mvrozanti revised this gist
Jun 25, 2024 . No changes.There are no files selected for viewing
-
mvrozanti renamed this gist
Jun 25, 2024 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -95,7 +95,8 @@ transparent = tocolor(0, 0, 0, 0) numJumps = tonumber(keyleds.config.numJumps) or 15 numSplits = tonumber(keyleds.config.numSplits) or 1 delay = tonumber(keyleds.config.delay) or 0.05 startColor = tocolor(keyleds.config.startColor) or tocolor(1, 0, 0) endColor = tocolor(keyleds.config.endColor) or tocolor(0, 1, 1) fadeTime = tonumber(keyleds.config.fadeTime) or 1 if type(keys) ~= "table" then @@ -151,7 +152,7 @@ end function lightUpKey(keyName, level, maxLevel) local percentage = level / maxLevel local color = interpolate(startColor, endColor, percentage) local key = getKeyFromName(keyName) if key then buffer[key] = fade(fadeTime, color, tocolor("black")) -
mvrozanti revised this gist
Jun 25, 2024 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -107,7 +107,6 @@ if type(keys) ~= "table" then end function init() buffer = RenderTarget:new() buffer:fill(tocolor('black')) end @@ -151,11 +150,6 @@ function interpolate(color1, color2, percentage) end function lightUpKey(keyName, level, maxLevel) local percentage = level / maxLevel local color = interpolate(tocolor(colors[1]), tocolor(colors[2]), percentage) local key = getKeyFromName(keyName) -
mvrozanti revised this gist
Jun 25, 2024 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ -- lightning.lua graph = { ["ESC"] = {"F1", "GRAVE", "1"}, ["F1"] = {"ESC", "F2", "1", "2", "3"}, @@ -92,9 +93,9 @@ graph = { keys = keyleds.db transparent = tocolor(0, 0, 0, 0) numJumps = tonumber(keyleds.config.numJumps) or 15 numSplits = tonumber(keyleds.config.numSplits) or 1 delay = tonumber(keyleds.config.delay) or 0.05 colors = keyleds.config.colors or {'red', 'cyan'} fadeTime = tonumber(keyleds.config.fadeTime) or 1 if type(keys) ~= "table" then @@ -136,7 +137,7 @@ function lightUpKeys(keyName, level, maxLevel) lightUpKey(keyName, level, maxLevel) local random_index = math.random(1, #neighbors) nextKey = neighbors[random_index] for i=1, numSplits do wait(delay) lightUpKeys(nextKey, level+1, maxLevel) end @@ -156,7 +157,7 @@ function lightUpKey(keyName, level, maxLevel) end visitedKeys[keyName] = currentTime local percentage = level / maxLevel local color = interpolate(tocolor(colors[1]), tocolor(colors[2]), percentage) local key = getKeyFromName(keyName) if key then buffer[key] = fade(fadeTime, color, tocolor("black")) -
mvrozanti created this gist
Jun 25, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,170 @@ graph = { ["ESC"] = {"F1", "GRAVE", "1"}, ["F1"] = {"ESC", "F2", "1", "2", "3"}, ["F2"] = {"F1", "F3", "2", "3"}, ["F3"] = {"F2", "F4", "3", "4", "5"}, ["F4"] = {"F3", "F5", "4", "5", "6"}, ["F5"] = {"F4", "5", "6", "7", "F6"}, ["F6"] = {"F5", "F7", "6", "7", "8"}, ["F7"] = {"F6", "F8", "7", "8", "9"}, ["F8"] = {"F7", "F9", "8", "9", "MINUS"}, ["F9"] = {"F8", "F10", "0", "MINUS", "EQUAL"}, ["F10"] = {"F9", "F11", "MINUS", "EQUAL", "BACKSPACE"}, ["F11"] = {"F10", "F12", "EQUAL", "BACKSPACE"}, ["F12"] = {"F11", "SYSRQ", "BACKSPACE", "INSERT"}, ["SYSRQ"] = {"F12", "BACKSPACE", "INSERT", "SCROLLLOCK", "HOME"}, ["SCROLLLOCK"] = {"SYSRQ", "PAUSE", "INSERT", "HOME", "PAGEUP"}, ["PAUSE"] = {"SCROLLLOCK", "HOME", "PAGEUP"}, ["GRAVE"] = {"ESC", "1", "Q", "TAB", "F1"}, ["1"] = {"GRAVE", "2", "W", "Q", "TAB", "ESC", "F1"}, ["2"] = {"1", "3", "F1", "F2", "Q", "W"}, ["3"] = {"2", "4", "F1", "F2", "F3", "W", "E", "R"}, ["4"] = {"3", "5", "F3", "F4", "E", "R"}, ["5"] = {"4", "6", "F4", "F5", "R", "T"}, ["6"] = {"5", "7", "F5", "F6", "T", "Y"}, ["7"] = {"6", "8", "F6", "F7", "Y", "U"}, ["8"] = {"7", "9", "F7", "F8", "U", "I"}, ["9"] = {"8", "0", "F8", "F9", "I", "O"}, ["0"] = {"9", "MINUS", "F9", "F10", "O", "P"}, ["MINUS"] = {"0", "EQUAL", "F8", "F9", "F10", "P", "LBRACE"}, ["EQUAL"] = {"MINUS", "BACKSPACE", "F10", "F11", "LBRACE", "RBRACE"}, ["BACKSPACE"] = {"EQUAL", "F11", "F12", "INSERT", "RBRACE", "BACKSLASH"}, ["TAB"] = {"Q", "W", "1", "GRAVE", "CAPSLOCK"}, ["Q"] = {"TAB", "W", "1", "2", "A"}, ["W"] = {"Q", "E", "2", "3", "A", "S"}, ["E"] = {"W", "R", "3", "4", "S", "D"}, ["R"] = {"E", "T", "4", "5", "D", "F"}, ["T"] = {"R", "Y", "5", "6", "F", "G"}, ["Y"] = {"T", "U", "6", "7", "G", "H"}, ["U"] = {"Y", "I", "7", "8", "H", "J"}, ["I"] = {"U", "O", "8", "9", "J", "K"}, ["O"] = {"I", "P", "9", "0", "K", "L"}, ["P"] = {"O", "LBRACE", "0", "MINUS", "L", "SEMICOLON"}, ["BACKSLASH"] = {"BACKSPACE", "RBRACE", "ENTER"}, ["LBRACE"] = {"P", "RBRACE", "MINUS", "EQUAL", "SEMICOLON", "APOSTROPHE"}, ["RBRACE"] = {"LBRACE", "BACKSPACE", "EQUAL", "APOSTROPHE", "ENTER"}, ["A"] = {"Q", "S", "TAB", "CAPSLOCK", "Z"}, ["S"] = {"A", "D", "W", "E", "Z", "X"}, ["D"] = {"S", "F", "E", "R", "X", "C"}, ["F"] = {"D", "G", "R", "T", "C", "V"}, ["G"] = {"F", "H", "T", "Y", "V", "B"}, ["H"] = {"G", "J", "Y", "U", "B", "N"}, ["J"] = {"H", "K", "U", "I", "N", "M"}, ["K"] = {"J", "L", "I", "O", "M", "COMMA"}, ["L"] = {"K", "SEMICOLON", "O", "P", "COMMA", "DOT"}, ["SEMICOLON"] = {"L", "APOSTROPHE", "P", "LBRACE", "DOT", "SLASH"}, ["APOSTROPHE"] = {"SEMICOLON", "ENTER", "LBRACE", "RBRACE", "SLASH"}, ["ENTER"] = {"APOSTROPHE", "RBRACE", "BACKSLASH", "RSHIFT"}, ["CAPSLOCK"] = {"A", "TAB", "LSHIFT"}, ["LSHIFT"] = {"CAPSLOCK", "A", "Z", "LCTRL"}, ["Z"] = {"A", "S", "LSHIFT", "X", "LCTRL"}, ["X"] = {"Z", "D", "LSHIFT", "C", "LALT"}, ["C"] = {"X", "F", "V", "LALT"}, ["V"] = {"C", "B", "F", "G"}, ["B"] = {"V", "N", "G", "H"}, ["N"] = {"B", "M", "H", "J"}, ["M"] = {"N", "COMMA", "J", "K"}, ["COMMA"] = {"M", "DOT", "K", "L"}, ["DOT"] = {"COMMA", "SLASH", "L", "SEMICOLON"}, ["SLASH"] = {"DOT", "APOSTROPHE", "SEMICOLON", "RSHIFT"}, ["RSHIFT"] = {"SLASH", "RCTRL", "ENTER", "APOSTROPHE"}, ["RCTRL"] = {"RSHIFT", "COMPOSE", "LEFT"}, ["LEFT"] = {"RCTRL", "UP", "DOWN", "RIGHT"}, ["UP"] = {"END", "LEFT", "DOWN", "RIGHT"}, ["DOWN"] = {"LEFT", "UP", "RIGHT"}, ["RIGHT"] = {"UP", "DOWN", "LEFT"}, ["LALT"] = {"Z", "X", "C", "LMETA", "SPACE"}, ["SPACE"] = {"LALT", "RALT", "Z", "X", "C", "V", "B", "N", "M", "COMMA"}, ["LCTRL"] = {"LSHIFT", "LMETA"}, ["LMETA"] = {"LCTRL", "LALT", "LSHIFT", "Z"}, ["DELETE"] = {"INSERT", "BACKSPACE", "BACKSLASH", "HOME", "END"}, ["HOME"] = {"INSERT", "DELETE", "SYSRQ", "SCROLLLOCK", "PAUSE", "PAGEUP", "PAGEDOWN"}, ["END"] = {"DELETE", "INSERT", "HOME", "END", "PAGEUP", "PAGEDOWN"}, ["PAGEUP"] = {"HOME", "SCROLLLOCK", "PAUSE", "END", "PAGEDOWN"}, ["PAGEDOWN"] = {"HOME", "PAGEUP", "END"}, ["COMPOSE"] = {"SLASH", "RSHIFT", "RCTRL", "FN"}, ["FN"] = {"RALT", "DOT", "SLASH", "RSHIFT", "COMPOSE"}, ["RALT"] = {"SPACE", "COMMA", "DOT", "FN", "SLASH"}, ["INSERT"] = {"BACKSPACE", "BACKSLASH", "F12", "SYSRQ", "DELETE", "HOME", "END", "SCROLLLOCK"} } keys = keyleds.db transparent = tocolor(0, 0, 0, 0) numJumps = tonumber(keyleds.config.numJumps) or 15 numStarts = tonumber(keyleds.config.numStarts) or 1 delay = tonumber(keyleds.config.delay) or 0.05 colors = keyleds.config.colors or {tocolor('red'), tocolor('white')} fadeTime = tonumber(keyleds.config.fadeTime) or 1 if type(keys) ~= "table" then local tempKeys = {} for i = 1, #keys do table.insert(tempKeys, keys[i]) end keys = tempKeys end function init() visitedKeys = {} buffer = RenderTarget:new() buffer:fill(tocolor('black')) end function onKeyEvent(key, isPress) if not isPress then return end if graph[key.name] then thread(lightUpKeys, key.name, 0, numJumps) end end function getKeyFromName(keyName) for _, key in ipairs(keys) do if key.name == keyName then return key end end end function lightUpKeys(keyName, level, maxLevel) if level >= maxLevel then return end local neighbors = graph[keyName] if neighbors == nil then print(keyName, '!!!') end if #neighbors == 0 then return end lightUpKey(keyName, level, maxLevel) local random_index = math.random(1, #neighbors) nextKey = neighbors[random_index] for i=1, numStarts do wait(delay) lightUpKeys(nextKey, level+1, maxLevel) end end function interpolate(color1, color2, percentage) local red = color1.red * (1 - percentage) + color2.red * percentage local green = color1.green * (1 - percentage) + color2.green * percentage local blue = color1.blue * (1 - percentage) + color2.blue * percentage return tocolor(red, green, blue) end function lightUpKey(keyName, level, maxLevel) local currentTime = os.clock() if visitedKeys[keyName] and (currentTime - visitedKeys[keyName] > fadeTime*2) then return end visitedKeys[keyName] = currentTime local percentage = level / maxLevel local color = interpolate(colors[1], colors[2], percentage) local key = getKeyFromName(keyName) if key then buffer[key] = fade(fadeTime, color, tocolor("black")) end end function render(ms, target) target:blend(buffer) end init()