xxxxxxxxxx
//Adapted from dan shiffman's example sketch from the processing website.
float yoff = 0.0; // 2nd dimension of perlin noise
void setup() {
size(640, 360);
}
void draw() {
background(255, 255, 0); // yellow sky
//noStroke();
stroke(0);
fill(100, 200, 255); // blue water
// We are going to draw a polygon out of the wave points
beginShape();
float xoff = 0; // Option #1: 2D Noise
//float xoff = yoff; // Option #2: 1D Noise
// Iterate over horizontal pixels
for (float x = 10; x <= width-10; x += 10) {
// Calculate a y value according to noise, map to
float y = map(noise(xoff, yoff), 0, 1, 200, 300); // Option #1: 2D Noise
// float y = map(noise(xoff), 0, 1, 200,300); // Option #2: 1D Noise
// Set the vertex
vertex(x, y);
// Increment x dimension for noise
xoff += 0.05;
}
// increment y dimension for noise
yoff += 0.01;
vertex(width-10, height-10);
vertex(10, height-10);
endShape(CLOSE);
}