xxxxxxxxxx
// * This sketch only really works in Processing * //
// Jason Cohen - Final Programming Project //
float yoff = .01; // 2nd dimension of perlin noise
PImage bg;
float noiseScale = 0.01; //change scale to get different outputs
float yShift = 0;
color aquaColor;
void setup() {
size(750, 750);
bg = loadImage("Untitled-1.png");
aquaColor = color (#B5D6F2);
}
void draw() {
background(bg);
noStroke();
fill(100, 200, 255); // light blue water
pushMatrix();
//translate(0, -100);
beginShape();
float xoff = 0.0002; // Option #1: 2D Noise
//float xoff = yoff; // Option #2: 1D Noise
// Iterate over horizontal pixels
for (float x = 0; x <= width; x = x + 15) {
// Calculate a y value according to noise, map to
float y = map(noise(xoff, yoff), 0, 1, 200, 300); // Option #1: 2D Noise
// Set the vertex
vertex(x, y);
// Increment x dimension for noise
xoff += 0.06;
}
// increment y dimension for noise
yoff += 0.01;
vertex(width, height);
vertex(0, height);
stroke(#B5D6F2);
strokeWeight(15);
endShape(CLOSE);
popMatrix();
yShift += .1;
for (int x =0; x<width; x+=2) {
for (int y = height-475; y<height; y+=2) {
float n = noise(x*noiseScale, y*noiseScale + yShift, hour() * .0002);
if ( n > .7) {
fill (aquaColor);
ellipse(x, y, 10, 10);
noStroke();
}
}
}
}