24 lines
469 B
JavaScript
24 lines
469 B
JavaScript
// 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);
|
|
}
|
|
|
|
} |