xxxxxxxxxx
51
let current;
let snowflake = [];
function setup() {
createCanvas(600, 600);
createSnowflake();
}
function createSnowflake(){
current = new Particle(width/2,random(10));
let done = false;
while(!done){
while(!current.finished() && !current.intersects(snowflake)){
current.update();
}
if(dist(width/2,0,current.pos.x,current.pos.y) < 10){
done = true;
}
snowflake.push(current);
current = new Particle(width/2,0);
}
}
function drawSnowflake(){
push();
//scale(0.1);
translate(width/2, height/2);
rotate(PI/6);
for(let i = 0; i < 6; i++){
rotate(PI/3);
for(let p of snowflake){
p.show();
}
push();
scale(1,-1);
for(let p of snowflake){
p.show();
}
pop();
}
pop();
}
function draw() {
background(0);
drawSnowflake();
}