xxxxxxxxxx
35
let myarray =[] ;
function setup() {
createGraphics(400,400,400);
for (let i = 0; i < 50; i++) {
myarray.push(new Jitter());
}
}
function draw() {
background(220);
for (let i = 0; i < myarray.length; i++) {
myarray[i].move();
myarray[i].display();
}
}
// Jitter class
class Jitter {
constructor() {
this.x = random(width);
this.y = random(height);
this.diameter = random(10, 30);
this.speed = 1;
}
move() {
this.x += random(-this.speed, this.speed);
this.y += random(-this.speed, this.speed);
}
display() {
ellipse(this.x, this.y, this.diameter, this.diameter);
}
}