xxxxxxxxxx
28
let smallSize = 50;
let largeSize = 200;
let currentSize = 0;
let destinationSize = smallSize;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// see if the mouse is less than the radius of the circle
// that means it's inside the circle
if (dist(mouseX, mouseY, width / 2, height / 2) < currentSize / 2) {
destinationSize = largeSize;
} else {
destinationSize = smallSize;
}
// SMOOTHING
// subtract where we are currently from where we want to be
// then scale that down and add that number back into the current number
currentSize += (destinationSize - currentSize) * 0.1;
circle(width / 2, height / 2, currentSize);
}