24 lines
469 B
JavaScript
Raw Normal View History

2023-01-18 16:18:38 +01:00
// Sketch 3.2: Capture mouse pressed and record locations!
var circles = [];
function setup() {
createCanvas(800, 800);
}
function draw() {
background("yellow");
if(mouseIsPressed) {
let v = createVector(mouseX, mouseY);
circles.push(v);
}
for(let i = 0; i < circles.length; i++) {
let c = circles[i];
let x = c.x + cos(frameCount * 0.1) * random(3);
let y = c.y + sin(frameCount * 0.1) * random(3);
circle(x, y, 10);
}
}