xxxxxxxxxx
43
let bg,colors,particle;
class Particle {
constructor(x,y,vx,vy,color,size) {
this.position = createVector(x,y);
this.velocity = createVector(vx,vy);
this.color = color;
this.size = size;
}
update() {
this.position.x += this.velocity.x;
this.position.y += this.velocity.y;
}
draw() {
noStroke();
fill(this.color);
circle(this.position.x,this.position.y,this.size);
}
}
function setup() {
// chromotome - sneaker
bg = color(255, 255, 255, 255);
colors = [
color(232, 22, 91, 255),
color(64, 30, 56, 255),
color(102, 195, 180, 255),
color(238, 119, 36, 255),
color(88, 64, 152, 255),
];
createCanvas(800, 800);
background(bg);
particle = new Particle(width/2,height/2,1.0,0.0,random(colors),25);
}
function draw() {
// background(bg);
particle.update();
particle.draw();
}