xxxxxxxxxx
// From one of Tomasz Sulej's (always interesting) tutorials:
// https://generateme.wordpress.com/
// No interaction, takes about 15 seconds to render.
// boolean, random, TWO_PI, sin, cos, noise, vertex
float yoff = random(1.0), incr = 0, r;
boolean squareOff;
int count = 0;
void setup() {
size(700, 650);
noFill();
background(20);
}
void draw() {
count++;
if (count < 700) squareOff = false;
else squareOff = true;
if (count > 820) {
noLoop();
}
drawShape();
}
void drawShape() {
if (squareOff) translate(width/2-40, height/2-40);
else translate(width/2, height/2);
incr += random(TWO_PI);
stroke(#87FC78, random(5.0, 20.0));
strokeWeight(random(1.0));
float xoff = random(1.0);
beginShape();
for (float ang = incr; ang < TWO_PI+incr; ang += random (TWO_PI/200.0)) {
// crude attempts to tame noise() in Javascript mode
if (!squareOff) r = map(noise(xoff, yoff*5.0), 0, 1, -100, 500);
else r = map(noise(xoff, yoff*5.0), 0, 1, -100, 600);
float x = r * cos(ang);
float y = r * sin(ang);
if (squareOff) {
float sx = x % 40;
float sy = y % 40;
int xx = (int)(x/40.0);
int yy = (int)(y/40.0);
x = xx*40.0 + (40.0-sx);
y = yy*40.0 + (40.0-sy);
}
vertex(x, y);
xoff += random(0.01, 0.05);
}
yoff += random(0.01, 0.05);
endShape(CLOSE);
}