let snowflakes = [];
function setup() {
createCanvas(600, 600);
fill(240);
noStroke();
}
function draw() {
background('#add8e6');
let t = frameCount / 1;
for (let i = 0; i < random(1); i++) {
snowflakes.push(new snowflake());
}
for (let flake of snowflakes) {
flake.update(t);
flake.display();
}
}
function snowflake() {
this.posX = 0;
this.posY = random(-50, 0);
this.initialangle = random(0, 2 * PI);
this.size = random(2, 5);
this.radius = sqrt(random(pow(width / 2, 2)));
this.update = function(time) {
let w = 0.6;
let angle = w * time + this.initialangle;
this.posX = width / 2 + this.radius * sin(angle);
this.posY += pow(this.size, 0.5);
if (this.posY > height) {
let index = snowflakes.indexOf(this);
snowflakes.splice(index, 1);
}
};
this.display = function() {
ellipse(this.posX, this.posY, this.size);
arc(300, 300, 50, 100,0 , 5)
arc(200, 300, 50, 100,0 , 5)
ellipse(250,300,300)
//ellipse(200, 300, 50, 100)
//elipse
fill('blue')
ellipse(250,300,300)
//arc
fill('aqua')
arc(300, 300, 50, 100,0 , 5)
arc(200, 300, 50, 100,0 , 5)
fill('#fe0000')
strokeWeight(0)
triangle(235,355,255,355,245,345)
//rect
fill(255)
strokeWeight(0)
rect(160,175,170,-10)
//triangle
fill(mouseX,mouseY,50)
stroke(0)
strokeWeight(0)
triangle(160,165,330,165,245,110)
//circle
fill(255)
strokeWeight(0)
circle(245,110,30)
//rect
fill(255)
stroke(0)
strokeWeight(1)
rect(random(165,170), random(380,390), 160, 20)
//rect(170, 390, 160, 10)
//line(170, 400, 330, 400)
rect(random(165,170), random(380,390), 140, 20)
rect(random(165,170), random(380,390), 120, 20)
rect(random(165,170), random(380,390), 100, 20)
rect(random(165,170), random(380,390), 80, 20)
rect(random(165,170), random(380,390), 60, 20)
rect(random(165,170), random(380,390), 40, 20)
rect(random(165,170), random(380,390), 20, 20)
//line(170, 400, 330, 400)
text(mouseX + "," + mouseY, 20, 20)
};
}
we hebben onze code bewerkt voor de snowflakes, maar we begonnen met: https://p5js.org/examples/simulate-snowflakes.html
helaas hebben we een paar dingen niet goed kunnen doen, omdat het vast begon te lopen on de laptop