Advertisement
Guest User

Offset.lua

a guest
Apr 9th, 2016
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. function init()
  2.   setName("Offset")
  3.   setDesc("Translates the image by a specified number of pixels")
  4.   setSize(100, 24+64+16+16+16+4)
  5.   addOutput(24+32)
  6.   addInput("Texture", 24+64+8)
  7.   addParameter("X", "The amount of pixels to offset by in the X axis", 24+64+16+8, 0, 0, getTileSize())
  8.   addParameter("Y", "The amount of pixels to offset by in the Y axis", 24+64+16+16+8, 0, 0, getTileSize())
  9. end
  10.  
  11. function apply()
  12.   size = getTileSize()
  13.   xOffset = getValue(1, 0, 0, 1)
  14.   yOffset = getValue(2, 0, 0, 1)
  15.   for i = 0, size * size - 1 do
  16.     p = getValue(0, i%size, math.floor(i/size), 1)
  17.     setPixel(0, (i%size) + xOffset, math.floor(i/size) + yOffset, p, p, p)
  18.   end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement