xxxxxxxxxx
var yoff = 0.0
var colors = [];
function setup() {
createCanvas(800,500);
//Generates random HEX color
function randomColor() {
var letters = "0123456789ABCDEF";
var color = "#";
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
//Adds 4 random colors to color array
for (var i = 0; i < 3; i++) {
colors.push(randomColor());
}
}
function draw() {
background(0);
for (var i = 0; i <= 2; i++) {
col = colors[i];
noStroke();
fill(col);
beginShape();
var xoff= i * 20;
for (var x = 0; x <= width; x += 10) {
// Map noise value (between 0 and 1) to y-value of canvas
var y = map(noise(xoff, yoff), 0, 1, i*150 + 50, 500);
// Set the vertex
vertex(x, y);
xoff += 0.05;
}
//Speed of moving waves
yoff += 0.01;
vertex(width, height);
vertex(0, height);
endShape(CLOSE);
}
}
function mousePressed() {
setup();
}