int iterations = 5000;
PVector[] snowflake = new PVector[iterations];
void setup() {
size(720, 720);
background(0);
for (int i = 0; i < iterations; i++) {
boolean stopped = false;
PVector current = new PVector(width / 2, 0);
while (!stopped) {
current.x -= 1;
current.y += random(-10, 10);
if (current.x <= 0) {
stopped = true;
} else {
for (int j = 0; j < i; j++) {
PVector point = snowflake[j];
float d = dist(point.x, point.y, current.x, current.y);
if (d <= 2) {
stopped = true;
break;
}
}
}
}
snowflake[i] = current;
}
}
void draw() {
translate(width / 2, height / 2);
noFill();
stroke(255);
for (int i = 0; i <= 360; i += 60) {
push();
rotate(radians(i));
for (PVector part : snowflake) {
point(part.x, part.y);
}
scale(1, -1);
for (PVector part : snowflake) {
point(part.x, part.y);
}
pop();
}
noLoop();
}
Comments