-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathGT_triangle.lua
43 lines (32 loc) · 1.12 KB
/
GT_triangle.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
-- luacheck: globals T r disp millis lcg_rnd
local M, module = {}, ...
_G[module] = M
function M.run()
-- make this a volatile module:
package.loaded[module] = nil
print("Running component triangle...")
local m
disp:setColor(0, 0, 80, 20)
disp:setColor(1, 60, 80, 20)
disp:setColor(2, 60, 120, 0)
disp:setColor(3, 0, 140, 30)
disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight())
disp:setColor(255, 255, 255)
disp:setPrintPos(2, 18)
disp:print("Triangle")
m = millis() + T
while millis() < m do
disp:setColor(bit.band(lcg_rnd(), 127)+127, bit.band(lcg_rnd(), 31), bit.band(lcg_rnd(), 127)+64)
disp:drawTriangle(
bit.rshift(lcg_rnd() * (disp:getWidth()), 8),
bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20,
bit.rshift(lcg_rnd() * (disp:getWidth()), 8),
bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20,
bit.rshift(lcg_rnd() * (disp:getWidth()), 8),
bit.rshift(lcg_rnd() * (disp:getHeight()-20), 8) + 20
)
tmr.wdclr()
end
print("...done")
end
return M