xxxxxxxxxx
ballx = 50;
bally = 50;
ballSize = 100;
grabbing = false;
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
}
function draw() {
background(100);
let d = dist(mouseX, mouseY, ballx, bally);
if (d < ballSize/2) {
grabbing = true;
} else if (grabbing & d < ballSize) {
grabbing = true;
} else {
grabbing = false;
}
if (grabbing) {
ballx = mouseX;
bally = mouseY;
fill(255, 10);
ellipse(ballx, bally, ballSize*2);
}
fill(255);
ellipse(ballx, bally, ballSize);
}