-
Notifications
You must be signed in to change notification settings - Fork 2
/
edge.lua
36 lines (35 loc) · 950 Bytes
/
edge.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
--made by rerere284
function init()
setName("Edge Distance")
setDesc("Gets how close things are to dark pixels")
setSize(100, 24+64+8+8+7+4)
addOutput(24+32)
addInput("Texture", 24+64+8+8)
end
function apply()
tileSize = getTileSize()
for i=0, tileSize*tileSize-1 do
ax = i%tileSize
ay = math.floor(i/tileSize)
closest = 9999999
for j=0, tileSize*tileSize-1 do
bx = j%tileSize
by = math.floor(j/tileSize)
ar, ag, ab = getValue(0, bx, by, 100.0) --get pixel at that location
--if i ~= j then
--dst = math.sqrt(((ax - bx)^2) + (ay - by)^2)/tileSize
dst = (math.abs(ax - bx) + math.abs(ay - by))/(tileSize*2)
brt = (ar + ag + ab)
--brt = math.sqrt((ar^2) + (ag^2) + (ab^2))
closeness = dst + (brt)
if closeness < closest then
closest = closeness
end
--end
end
fr = closest
fg = closest
fb = closest
setPixel(0, ax, ay, fr, fg, fb)
end
end