SketchBook

Sea Side

var xoff, yoff;

var time;

var colors = [];

function setup() {
createCanvas(windowWidth,
windowHeight);
background(50, 50, 50);

noFill();

colors.push(color(250, 240, 300, 250));
  colors.push(color(200, 120, 300, 300));
colors.push(color(300, 75, 300, 300));
colors.push(color(200, 370, 260, 128));
colors.push(color(200, 250, 180, 128));
 colors.push(color(160, 250, 200, 150));
 xoff = 5.0;
yoff = 4.0;

time = 0;
}

function draw() {

var c = getColor(time);
stroke(c);

beginShape();
var xoff = 0;
for (var x = 0; x <= windowWidth; x += 7) {
var y = map(noise(xoff, yoff), 0, 1, 0, windowHeight);
curveVertex(x, y);
xoff += 0.02;
}
yoff += 0.001;
curveVertex(windowWidth,
windowHeight);
endShape();

time = time + 0.001;

if (time > 1.0) {
time = 0;
}
}

function getColor(t) {
var p = t * (colors.length - 1);
var from = floor(p);
return lerpColor(colors[from], colors[from + 1], p - from);
}