-
Notifications
You must be signed in to change notification settings - Fork 0
/
patterns.lua
52 lines (44 loc) · 1.01 KB
/
patterns.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local patterns = {}
local function loadPattern(pn)
local f, err = loadfile("patt_" .. pn .. ".lua")
if f then
local p = f()
patterns[pn] = p
return p
end
errorLog(err)
end
-- auto-load additional patterns from external files
setmetatable(patterns, {
__index = function(patterns, k)
return loadPattern(k)
end,
--__mode = "kv",
})
local random = math.random
---- STROBO ----
do
local on = false
patterns.strobo = function(wsbuf)
if on then
wsbuf:fill(0, 0, 0)
else
wsbuf:fill(255, 255, 255)
end
on = not on
return 1
end
end
patterns.rstrobo = function(wsbuf)
local r, g, b = random(0, 255), random(0, 255), random(0, 255)
wsbuf:fill(g, r, b)
return 50
end
patterns.allcolors = function(wsbuf)
local set = wsbuf.set
for i = 1, wsbuf:size() do
local r, g, b = random(0, 255), random(0, 255), random(0, 255)
set(wsbuf, i, g, r, b)
end
end
return patterns