-
Notifications
You must be signed in to change notification settings - Fork 2
/
square.lua
33 lines (30 loc) · 1 KB
/
square.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("Square pattern")
setDesc("Used for checkerboards and other square patterns.")
setSize(100, 24+64+8+8+18+7+4)
addOutput(24+32)
addInputParameter("Size", "How many squares to split it into", 24+64+8+8, 3, 1, -1)
addInputParameter("Colors", "Number of colors", 24+64+8+8+18, 2, 1, -1)
end
function floorto(a,b)
return math.floor(a/b)*b
end
function apply()
tileSize = getTileSize()
for i=0, tileSize*tileSize-1 do
x = i%tileSize
y = math.floor(i/tileSize)
ar, ag, ab = getValue(0, x, y, 1) --get pixels at that location for both
br, bg, bb = getValue(1, x, y, 1)
--siz = floorto((ar+ag+ab)/3 , 1/tileSize)
siz = 2^((ar+ag+ab)/3) --glitches out with any other numbers, for some reason.
--not based on tileSize either
col = (br+bg+bb)/3
f = (floorto(x/tileSize,1/siz) + floorto(y/tileSize,1/siz))
f = f * siz/col
f = f % 1
f = f * (col/(col-1))
setPixel(0, x, y, f, f, f)
end
end