-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathregulate.lua
33 lines (31 loc) · 914 Bytes
/
regulate.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
--made by rerere284
function init()
setName("Regulate")
setDesc("Modulo + Rounding")
setSize(100, 24+64+8+8+18+18+7+4)
addOutput(24+32)
addInput("Texture", 24+64+8+8)
addParameter("Modulo", "Loops over this value", 24+64+8+8+18, 10, 1, -1)
addParameter("Rounding", "Snaps to this value", 24+64+8+8+18+18, 1, 1, -1)
end
function rnd(h)
if (h*100) % 1 > 0.5 then
return math.ceil(h*100)/100
else
return math.floor(h*100)/100
end
end
function apply()
tileSize = getTileSize()
for i=0, tileSize*tileSize-1 do
x = i%tileSize
y = math.floor(i/tileSize)
mod = getValue(1, 0, 0, 1)/100
round = getValue(2, 0, 0, 1)/100
ar, ag, ab = getValue(0, x, y, 1) --get pixel at that location
fr = (rnd((ar % mod) * round)) / round
fg = (rnd((ag % mod) * round)) / round
fb = (rnd((ab % mod) * round)) / round
setPixel(0, x, y, fr, fg, fb)
end
end