Advertisement
Dermotb

Noise

Apr 1st, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. supportedOrientations(LANDSCAPE_ANY)
  2.  
  3. -- Use this function to perform your initial setup
  4. function setup()
  5. parameter.number("noiseScale", 1/30, 1, 1/5)
  6. parameter.number("noiseSpeed", 0.05, 1, 0.2)
  7. parameter.integer("Red",0,255,0) --these parameters added
  8. parameter.integer("Blue",0,255,255)
  9. parameter.integer("Green",0,255,150)
  10. parameter.integer("Alpha",0,255,0)
  11.  
  12. tileSize = WIDTH/24
  13. noisePos = vec2(0,0)
  14.  
  15. tiles = {}
  16. for x = 1, WIDTH/tileSize do
  17. tiles[x] = {}
  18. for y = 1, HEIGHT/tileSize do
  19. tiles[x][y] = noise(x * noiseScale, y * noiseScale)
  20. end
  21. end
  22. end
  23.  
  24. function moveNoise()
  25. for x,column in ipairs(tiles) do
  26. for y,value in ipairs(column) do
  27. tiles[x][y] = noise(x * noiseScale + noisePos.x, y * noiseScale + noisePos.y)
  28. end
  29. end
  30. end
  31.  
  32. -- This function gets called once every frame
  33. function draw()
  34. background(0, 0, 0, 255)
  35. pushStyle()
  36. noStroke()
  37. noSmooth()
  38.  
  39. for x,column in ipairs(tiles) do
  40. for y,value in ipairs(column) do
  41. fill((value+1)*0.5*255)
  42. rect((x-1)*tileSize, (y-1)*tileSize, tileSize, tileSize)
  43. end
  44. end
  45.  
  46. noisePos = noisePos + vec2(0.5,0.3) * noiseSpeed
  47. moveNoise()
  48. fill(Red,Green,Blue,Alpha) --added
  49. rect(1,1,WIDTH,HEIGHT) --added
  50. strokeWidth(5)
  51. stroke(0)
  52. fontSize(36)
  53. textMode(CORNER)
  54. fill(0)
  55. text("r="..Red,50,HEIGHT-300) -- these text lines added
  56. text("b="..Blue,50,HEIGHT-350)
  57. text("g="..Green,50,HEIGHT-400)
  58. text("a="..Alpha,50,HEIGHT-450)
  59. popStyle()
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement