-
Notifications
You must be signed in to change notification settings - Fork 0
/
patt_huetwist.lua
34 lines (32 loc) · 1007 Bytes
/
patt_huetwist.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
local curhue=1
local PIXELS = 30*5
local function run(wsbuf, p, nofade, twistwidtharg)
local TWISTWIDTH = 16
if type(twistwidtharg) == "number" and twistwidtharg > 1 and twistwidtharg < 128 then
TWISTWIDTH = twistwidtharg
end
local huequant = 128/TWISTWIDTH
if nofade == 1 then
curhue = p:getHue()
end
for pixel = 1, (PIXELS-TWISTWIDTH)/2 do
wsbuf:set(pixel, hue2rgb(curhue % 256, p.brightness))
end
for v = 1, TWISTWIDTH/2 do
local pixel = ((PIXELS-TWISTWIDTH)/2) + v
local ih = (curhue + (huequant*v))
wsbuf:set(pixel, hue2rgb(ih % 256, p.brightness / v ))
end
for v = TWISTWIDTH/2, TWISTWIDTH do
local pixel = ((PIXELS-TWISTWIDTH)/2) + v
local ih = (curhue + (huequant*v))
local bs = TWISTWIDTH-v+1
wsbuf:set(pixel, hue2rgb(ih % 256, p.brightness / bs))
end
for pixel = (PIXELS+TWISTWIDTH)/2, PIXELS do
wsbuf:set(pixel, hue2rgb((curhue + 128) % 256 , p.brightness))
end
curhue = (curhue +1) % 255
return 20 + ((5000 * (255 - p.speed)) / 255)
end
return run