xxxxxxxxxx
56
let particles = []
function setup() {
createCanvas(windowWidth, windowHeight);
}
function windowResized(){
resizeCanvas(windowWidth, windowHeight);
}
function draw() {
background(0,10);
noStroke();
fill(random(0,255), random(0,255), random(0,255));
triangle(width/2-30, height, width/2+30, height, width/2, height-50);
particles.push(new Particle());
for (let i=particles.length-1; i>=0; i--){
particles[i].show();
particles[i].update();
if (particles[i].alpha < 0){
particles.splice(i,1);
}
}
}
class Particle{
constructor() {
this.x1 = width / 2;
this.y1 = height - 50;
this.x2 = this.x1;
this.y2 = this.y1 + 10;
this.r = random(0, 255);
this.g = random(0, 255);
this.b = random(0, 255);
this.alpha = 255;
this.size = random(25,40);
this.changeX = random(-1, 1);
this.changeY = random(-7, -4);
this.acc = 0.05;
}
show() {
strokeWeight(3);
stroke(this.r, this.g, this.b, this.alpha);
line(this.x1, this.y1, this.x2, this.y2);
}
update() {
this.x1 += this.changeX;
this.y1 += this.changeY;
this.x2 += this.changeX;
this.y2 += this.changeY;
this.changeY += this.acc;
this.alpha -= 1;
}
}