Advertisement
Guest User

MTX Rotate

a guest
May 9th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement