xxxxxxxxxx
68
let cursor, r, g, b, a, circles;
let posX = [];
let posY = [];
let posMax = 25;
function setup() {
createCanvas(windowWidth, windowHeight);
noCursor()
cursor = new Cursor();
}
function draw() {
cursor.draw();
}
class Cursor {
constructor() {
this.x = -200;
this.y = -200
this.width = 0;
this.heigth = 0;
}
draw() {
clear();
posX.unshift(mouseX);
posY.unshift(mouseY);
if (posX.length > posMax) {
posX.pop();
posY.pop();
}
for (let i = posX.length - 1; i >= 0; --i) {
let diametro = posMax - i;
this.x = posX[i];
this.y = posY[i];
this.width = diametro;
this.heigth = diametro;
this.color = [r, g, b, a];
this.mouseMoved()
ellipse(this.x, this.y, this.width, this.heigth);
}
}
mouseMoved(){
r = random(0, 255);
g = random(0, 255);
b = random(0, 255);
a = random(0, 255);
window.addEventListener('mousemove', evt => {
fill(r, g, b, a);
})
}
}