xxxxxxxxxx
let particles=[]
// let colors = ["#7dce82","#ff8360","#fedc97"]
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
for(let i=0;i<300;i++){
let newP = new Particle({
// p: createVector(random(width),random(height)),
// p: createVector(0,i),
v: createVector(random(-2,2),random(-2,2)).mult(2),
p: createVector(width/2,height/2),
// v: createVector(1,0),
color:random(255),
a: createVector(0,0),
r: random(3)*random()
})
particles.push(newP)
}
}
function draw() {
if (mouseIsPressed){
let newP = new Particle({
p: createVector(random(width),random(height)),
// p: createVector(0,i),
v: createVector(random(-2,2),random(-2,2)),
// p: createVector(mouseX,mouseY),
// v: createVector(1,0),
a: createVector(0,0),
r: random(3)*random()
})
particles.push(newP)
}
particles.forEach(p=>{
p.update()
p.draw()
})
// p.add(v)
// v.add(a)
// v.x+=sin(p.y/10)*0.5
// v.y+=sin(p.y/20)*0.5
// v.x =random(-5,5)
// v.y =random(-5,5)
// fill(p.x/3,p.y/3,frameCount)
// noStroke()
// circle(p.x,p.y, r);
}