xxxxxxxxxx
let particles=[]
// let colors = ["#e9d985","#b2bd7e", "#749c75", "#6a5d7b","#5d4a66"]
let colors = "1c3144-d00000-ffba08-a2aebb-3f88c5".split("-").map(a=>"#"+a)
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
for(let i=0;i<100;i++){
let newP = new Particle({
// p: createVector(random(width),random(height)),
// p: createVector(0,i),
v: createVector(0,2).rotate(random(10)),
p: createVector(width/2,height/2),
// v: createVector(1,0),
color: color(random(colors)),
color2: color(255,0,0),
a: createVector(0,0),
r: random(200)*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),
color: color(0),
a: createVector(0,0),
r: random(5)*random()
})
particles.push(newP)
}
particles.forEach(p=>{
p.update()
p.draw()
})
particles= particles.filter(p=>p.life>0)
// 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);
}