rerere284

direction

Apr 12th, 2016
200
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --made by rerere284
  2. function init()
  3.     setName("Direction")
  4.     setDesc("Direction from center")
  5.     setSize(100, 24+64+8+8+7+4)
  6.     addOutput(24+32)
  7.     addParameter("Offset", "Rotational offset", 24+64+8+8, 0, -1, -1)
  8. end
  9.  
  10. function apply()
  11.     tileSize = getTileSize()
  12.     math.randomseed(getValue(2, 0, 0, 1))
  13.     for i=0, tileSize*tileSize-1 do
  14.         x = (i%tileSize)
  15.         y = (math.floor(i/tileSize))
  16.         px = x - (tileSize/2)
  17.         py = y - (tileSize/2)
  18.         rot = math.atan2(py,px)/(math.pi*2) + (90/360) + (getValue(0, 0, 0, 1)/360)
  19.         setPixel(0, x, y, rot, rot, rot)
  20.     end
  21. end
RAW Paste Data