xxxxxxxxxx
24
let x, y, w, h;
let dx, dy;
function setup() {
createCanvas(800, 600);
x = width / 2;
y = height / 2;
w = width / 5;
h = height / 5;
rectMode(CENTER);
}
function draw() {
background(20);
noStroke();
fill(255, 10, 100);
rect(x, y, w, h);
dx = mouseX - x;
dy = mouseY - y;
x = x + dx * 0.05;
y = y + dy * 0.05;
}