Advertisement
Guest User

StripesInc

a guest
Oct 31st, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. function init()
  2.     setName("StripesInc")
  3.     setDesc("Generate striped texture")
  4.     setSize(100,24+32+24+64+8+8+7+4+18+18+18)
  5.     addOutput(24+32)
  6.     addOutput(64+24+32+8)
  7.     addInputParameter("Intensity","Intensity",64+7+24+64+8+8,100,0,100,true)
  8.     addParameter("Increments","Vertical value variation",64+7+18+24+64+8+8,50,0,100)
  9.     addParameter("Seed","Random seed",64+7+18+18+24+64+8+8,0,0,255)
  10. end
  11. -- Ugly way to use channels
  12. function apply()
  13.     math.randomseed (getValue(2,0,0,1))
  14.     colorval = math.random()
  15.     tileSize = getTileSize()
  16.     for i=0, tileSize*tileSize-1 do
  17.         x = i%tileSize
  18.         y = math.floor(i/tileSize)
  19.         if (x == 0) then
  20.             if (math.random() > 0.5) then
  21.                 colorval = colorval + getValue(1,0,0,100)
  22.             else
  23.                 colorval = colorval - getValue(1,0,0,100)
  24.             end
  25.         end
  26.         if (colorval < 0) then
  27.                 colorval = 0
  28.             end
  29.             if (colorval > 1) then
  30.                 colorval = 1
  31.             end
  32.         setPixel(0,x,y,colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100))
  33.         setPixel(1,y,x,colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100),colorval*getValue(0,0,0,100))
  34.     end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement