Skip to content

Instantly share code, notes, and snippets.

@gbluma
Created January 17, 2015 00:29
Show Gist options
  • Save gbluma/590092e2edc960de8489 to your computer and use it in GitHub Desktop.
Save gbluma/590092e2edc960de8489 to your computer and use it in GitHub Desktop.
float n() {
return random(50);
}
float[] soften(float[] curve) {
for (int i=0; i<19;i++){
curve[i] = curve[i] + (curve[i]-curve[i+1])/5;
}
for (int i=19; i>0; i--){
curve[i] = curve[i] + (curve[i-1]-curve[i])/5;
}
return curve;
}
void setup()
{
size(600,600);
background(255);
smooth();
noFill();
rectMode(CENTER);
// start with random noise
float[] curve = { n(),n(),n(),n(),n(), n(),n(),n(),n(),n(),n(),n(),n(),n(),n(), n(),n(),n(),n(),n()};
// soften curve
curve = soften(curve);
curve = soften(curve);
curve = soften(curve);
// over 100 steps, alter the shape
for(int y=0; y<300; y++) {
stroke(255-log(random(1)+1)*130);
strokeWeight(log(random(20)+1));
beginShape();
for(int x=0; x<20; x++) {
curve[x] *= 0.9+random(0.2);
curveVertex(x*100-200,curve[x]+(y*3+random(1)-100));
}
endShape();
}
tint(0,0,255);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment