Guest User

MTX Rotate

a guest
May 9th, 2020
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function init()
  2.     setName("MTX Rotate")
  3.     setDesc("A Rotation Matrix")
  4.     setSize(120,18+18+18+24+64+8+8+7+4)
  5.     addOutput(24+32)
  6.     addInput("Texture",24+64+8+8)
  7.     addInputParameter("Rotation","Image Rotation",18+24+64+8+8,0,0,255)
  8.     addParameter("Center X","X of the center of rotation",18+18+24+64+8+8,getTileSize()/2,0,getTileSize())
  9.     addParameter("Center Y","Y of the center of rotation",18+18+18+24+64+8+8,getTileSize()/2,0,getTileSize())
  10. end
  11. -- Ugly way to use channels
  12. function apply()
  13.     x = 0
  14.     y = 0
  15.     tileSize = getTileSize()
  16.     for i=0, tileSize*tileSize-1 do
  17.         x = i%tileSize
  18.         y = math.floor(i/tileSize)
  19.         Tx = x-getValue(2,0,0,1)
  20.         Ty = y-getValue(3,0,0,1)
  21.         teta = math.rad(getValue(1,x,y,255)*360)
  22.         outr, outg, outb = getValue(0,math.floor((Tx*math.cos(teta))-(Ty*math.sin(teta)))+getValue(2,0,0,1),math.floor((Ty*math.cos(teta))+(Tx*math.sin(teta)))+getValue(3,0,0,1),1)
  23.         setPixel(0,x,y,outr,outg,outb)
  24.     end
  25. 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.

×