Guest User

simple_color.lua

a guest
Apr 9th, 2016
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. function init()
  2.   setName("Simple Color")
  3.   setDesc("Colors the image using one set color.")
  4.   setSize(100, 24+64+16+16+16+16+16+4)
  5.   addOutput(24+32)
  6.   addInput("Texture", 24+64+8)
  7.   addParameter("Red", "The red value.", 24+64+16+8, 0, 0, 255)
  8.   addParameter("Green", "The green value.", 24+64+16+16+8, 0, 0, 255)
  9.   addParameter("Blue", "The blue value.", 24+64+16+16+16+8, 0, 0, 255)
  10.   addParameter("Quantize", "Reduces the number of shades used.", 24+64+16+16+16+16+8, 1, 1, 100)
  11. end
  12.  
  13. function apply()
  14.   size = getTileSize()
  15.   red = getValue(1, 0, 0, 255)
  16.   green = getValue(2, 0, 0, 255)
  17.   blue = getValue(3, 0, 0, 255)
  18.   q = getValue(4, 0, 0, 1)
  19.  
  20.   for x = 0, size do
  21.     for y = 0, size do
  22.       p = getValue(0, x, y, 1) * 100
  23.       p = (math.floor(p / q) * q) / 100
  24.       setPixel(0, x, y, red * p, green * p, blue * p)
  25.     end
  26.   end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment