rerere284

distance

Apr 12th, 2016
190
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --made by rerere284
  2. function init()
  3.     setName("Distance")
  4.     setDesc("Gets the distance between two numbers")
  5.     setSize(100, 24+64+8+8+18+7+4)
  6.     addOutput(24+32)
  7.     addInputParameter("First", "First Number", 24+64+8+8, 1, -1, -1)
  8.     addInputParameter("Second", "Second Number", 24+64+8+8+18, 1, -1, -1)
  9. end
  10.  
  11. function apply()
  12.     tileSize = getTileSize()
  13.     for i=0, tileSize*tileSize-1 do
  14.         x = i%tileSize
  15.         y = math.floor(i/tileSize)
  16.         ar, ag, ab = getValue(0, x, y, 100.0) --get pixels at that location
  17.         br, bg, bb = getValue(1, x, y, 100.0)
  18.         fr = math.abs(ar - br)
  19.         fg = math.abs(ag - bg)
  20.         fb = math.abs(ab - bb)
  21.         setPixel(0, x, y, fr, fg, fb)
  22.     end
  23. end
RAW Paste Data