xxxxxxxxxx
float NOISE_SCALE = 0.004f;
int STEP = 20;
int count;
public void setup() {
size (900, 400);
strokeWeight(1);
noFill();
count = (int)(width*1.5/STEP);
background(0);
}
void drawPerlinCurve (float x, float y, float phase, float step, int count, color myColour) {
pushStyle();
stroke(200,100);
beginShape();
for (int i=0; i<count; i++) {
curveVertex(x, y);
float angle = 2*PI*noise(x* NOISE_SCALE, y* NOISE_SCALE, phase* NOISE_SCALE);
x += cos(angle)*step;
y += sin(angle)*step;
}
endShape();
popStyle();
}
public void draw() {
//background(0);
pushStyle();
fill(0,16);
rect(0,0,width, height);
popStyle();
float phase = frameCount / 2f;
for (int y = 0; y < height; y+=10) {
color myColour = lerpColor(color(204, 51, 0), color(102, 153, 51), y / (float) height);
drawPerlinCurve(width+50, y, phase, STEP, count, myColour);
}
}