Guest User

Offset.lua

a guest
Apr 9th, 2016
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×