xxxxxxxxxx
let particles = []
let colors = "083d77-ee964b-042a2b-5eb1bf-cdedf6-ef7b45-d84727-ffdde2-efd6d2-ff8cc6-de369d".split("-").map(a=>"#"+a)
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
for(let i=0;i<300;i++){
let newP = new Particle({
//de bug 時可以用滑鼠數值來 print 監測
p:createVector(random(width),random(height)),
//p:createVector(0,i),
//初始位置改成線
// v:createVector(random(-1,1),random(-1,1)),
//p: createVector(width/2,height/2),
v: createVector(3,3).rotate(random()*2*PI),
a: createVector(0,0),
r: random(30)*random(),
clr: random(colors)
//random() = 0~1
})
particles.push(newP)
// p = 位置 , v =速度 a = 加速度
//p = createVector(width/2,height/2);
//v = createVector(1,0);
//a = createVector(0,0.1);
}
}
function draw() {
particles.forEach(p=>{
p.update()
p.draw()
}
)
//p.add(v)
//v.add(a)
//v.x+=sin(p.y/8)
//v.y+=cos(p.y/8)
//v.x = random(-5,10)
//v.y = random(-5,10)
//r = random(-5,10)
//fill(255,p.y/3,255)
//noStroke()
//circle(p.x,p.y, frameCount);
}