xxxxxxxxxx
51
let tms = []; //sets up array?
let numMakers = 10;
function setup() {
createCanvas(windowWidth, windowHeight);
background(220);
frameRate(20);
}
function draw() {
for(let i = 0; i < tms.length; i = i + 1) {
tms[i].update();
}
background(255, 3);
}
function mouseDragged() {
let w = random(1, 7);
let h = random(1, 7);
let tm = new trailMaker(
mouseX, // x
mouseY, // y
w, // width
h // height
);
tms.push(tm);
}
class trailMaker {
constructor(x, y, w, h, xSpeed, ySpeed) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
update() {
if (this.h > this.w) {
fill(random(0, 125));
} else {
fill(random(125, 255));
}
noStroke();
ellipse(this.x, this.y, this.w, this.h);
this.x = this.x + random(-10, 10);
this.y = this.y + random(-10, 10);
}
}