SHARE
TWEET

square_pattern

rerere284 Apr 12th, 2016 (edited) 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --made by rerere284
  2. function init()
  3.     setName("Square pattern")
  4.     setDesc("Used for checkerboards and other square patterns.")
  5.     setSize(100, 24+64+8+8+18+7+4)
  6.     addOutput(24+32)
  7.     addInputParameter("Size", "How many squares to split it into", 24+64+8+8, 3, 1, -1)
  8.     addInputParameter("Colors", "Number of colors", 24+64+8+8+18, 2, 1, -1)
  9. end
  10.  
  11. function floorto(a,b)
  12.     return math.floor(a/b)*b
  13. end
  14.  
  15. function apply()
  16.     tileSize = getTileSize()
  17.    
  18.     for i=0, tileSize*tileSize-1 do
  19.         x = i%tileSize
  20.         y = math.floor(i/tileSize)
  21.         ar, ag, ab = getValue(0, x, y, 1) --get pixels at that location for both
  22.         br, bg, bb = getValue(1, x, y, 1)
  23.         --siz = floorto((ar+ag+ab)/3 , 1/tileSize)
  24.         siz = 2^((ar+ag+ab)/3) --glitches out with any other numbers, for some reason.
  25.                                     --not based on tileSize either
  26.         col = (br+bg+bb)/3
  27.         f = (floorto(x/tileSize,1/siz) + floorto(y/tileSize,1/siz))
  28.         f = f * siz/col
  29.         f = f % 1
  30.         f = f * (col/(col-1))
  31.         setPixel(0, x, y, f, f, f)
  32.     end
  33. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top