Skip to content

Instantly share code, notes, and snippets.

@dermotbalson
Created April 9, 2013 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dermotbalson/5346256 to your computer and use it in GitHub Desktop.
Save dermotbalson/5346256 to your computer and use it in GitHub Desktop.
21.Noise
supportedOrientations(LANDSCAPE_ANY)
-- Use this function to perform your initial setup
function setup()
parameter.number("noiseScale", 1/30, 1, 1/5)
parameter.number("noiseSpeed", 0.05, 1, 0.2)
parameter.integer("Red",0,255,0) --these parameters added
parameter.integer("Blue",0,255,255)
parameter.integer("Green",0,255,150)
parameter.integer("Alpha",0,255,0)
tileSize = WIDTH/24
noisePos = vec2(0,0)
tiles = {}
for x = 1, WIDTH/tileSize do
tiles[x] = {}
for y = 1, HEIGHT/tileSize do
tiles[x][y] = noise(x * noiseScale, y * noiseScale)
end
end
end
function moveNoise()
for x,column in ipairs(tiles) do
for y,value in ipairs(column) do
tiles[x][y] = noise(x * noiseScale + noisePos.x, y * noiseScale + noisePos.y)
end
end
end
-- This function gets called once every frame
function draw()
background(0, 0, 0, 255)
pushStyle()
noStroke()
noSmooth()
for x,column in ipairs(tiles) do
for y,value in ipairs(column) do
fill((value+1)*0.5*255)
rect((x-1)*tileSize, (y-1)*tileSize, tileSize, tileSize)
end
end
noisePos = noisePos + vec2(0.5,0.3) * noiseSpeed
moveNoise()
fill(Red,Green,Blue,Alpha) --added
rect(1,1,WIDTH,HEIGHT) --added
strokeWidth(5)
stroke(0)
fontSize(36)
textMode(CORNER)
fill(0)
text("r="..Red,50,HEIGHT-300) -- these text lines added
text("b="..Blue,50,HEIGHT-350)
text("g="..Green,50,HEIGHT-400)
text("a="..Alpha,50,HEIGHT-450)
popStyle()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment