xxxxxxxxxx
28
let px, py;
function setup() {
createCanvas(400, 400);
fill(0);
noStroke();
px = mouseX; // initialize the previous shape position
py = mouseY;
}
function draw() {
if(mouseIsPressed) { // is the mouse pressed ?
// calculate the distance between the mouse and the previous shape
let distance = dist(px,py,mouseX, mouseY);
if(distance > 10){ // checking if that distance is big enough
circle(mouseX, mouseY,10); // drawing the circle
px = mouseX; // update previous shape position
py = mouseY;
}
}
}