Project 11

sketchDownload
var x = 0;
var backgroundValue = [];
var noiseParam = 0;
var noiseStep = 0.1;


function setup() {
    createCanvas(480, 400);
    frameRate(15);
    var ilength = (width/5) + 1
    for (i = 0; i < ilength; i++) {
    	var n = noise(noiseParam);
    	var value = map(n, 0, 1, 0, height);
    	backgroundValue.push(value);
    	noiseParam += noiseStep
    } 
}

function draw() {
	var size = random(50, 150);
	background(166, 238, 255);
	stroke(160, 160, 255);
	strokeWeight(10);
	backgroundValue.shift();
	var x2 = 0;
	var ilength = (width/5) + 1
	var n = noise(noiseParam);
    var value = map(n, 0, 1, 0, height);
    backgroundValue.push(value);
    noiseParam += noiseStep
    for (i = 0; i < ilength; i++) {
		beginShape();
		curveVertex(x2, backgroundValue[i]);
		curveVertex(x2, backgroundValue[i]);
		curveVertex(x2, height);
		curveVertex(x2 + 5, backgroundValue[i + 1]);
		curveVertex(x2 + 5, backgroundValue[i + 1]);
		endShape(CLOSE);
		x2 += 5
	}
	noStroke();
	fill(color(random(255), random(255), random(255)));
    coral(x, size);
    x += 1
    if (x > 480) {
        x = 0;
    }
}

function coral(x, size) {
    beginShape();
    curveVertex(x, 400);
    curveVertex(x, 400);
    curveVertex(x + 5, size*3);
    curveVertex(x - 20, size*2);
    curveVertex(x + 5, size*2 - 5);
    curveVertex(x - 10, size);
    curveVertex(x, size + 5);
    curveVertex(x + 10, size*2 - 20);
    curveVertex(x + 20, size*3);
    curveVertex(x + 20, size*4);
    curveVertex(x + 70, size);
    curveVertex(x + 80, size*2);
    curveVertex(x + 50, 400);
    curveVertex(x + 50, 400);
    endShape(CLOSE);
}

Leave a Reply