xxxxxxxxxx
28
let mPos = [];
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(220, 20, 120);
// update
for (let i = 0; i < mPos.length; i++) {
mPos[i].w *= 0.95;
if (mPos[i].w < 0.5) {
mPos.splice(i, 1);
}
}
// draw
for (let i = 1; i < mPos.length; i++) {
strokeWeight(mPos[i].w);
line(mPos[i].x, mPos[i].y, mPos[i - 1].x, mPos[i - 1].y);
}
}
function mouseMoved() {
mPos.push({ x: mouseX, y: mouseY, w: 24 });
}