-
Notifications
You must be signed in to change notification settings - Fork 2
/
stripesinc.lua
35 lines (35 loc) · 1.09 KB
/
stripesinc.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
function init()
setName("StripesInc")
setDesc("Generate striped texture")
setSize(100,24+32+24+64+8+8+7+4+18+18+18)
addOutput(24+32)
addOutput(64+24+32+8)
addInputParameter("Intensity","Intensity",64+7+24+64+8+8,100,0,100,true)
addParameter("Increments","Vertical value variation",64+7+18+24+64+8+8,50,0,100)
addParameter("Seed","Random seed",64+7+18+18+24+64+8+8,0,0,255)
end
-- Ugly way to use channels
function apply()
math.randomseed (getValue(2,0,0,1))
colorval = math.random()
tileSize = getTileSize()
for i=0, tileSize*tileSize-1 do
x = i%tileSize
y = math.floor(i/tileSize)
if (x == 0) then
if (math.random() > 0.5) then
colorval = colorval + getValue(1,0,0,100)
else
colorval = colorval - getValue(1,0,0,100)
end
end
if (colorval < 0) then
colorval = 0
end
if (colorval > 1) then
colorval = 1
end
setPixel(0,x,y,colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100))
setPixel(1,y,x,colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100))
end
end