xxxxxxxxxx
32
let width=800;
let height=600;
let x=width/2;
let y=height/2;
let slow=20;
let r=45;
function setup() {
createCanvas(width, height);
}
function draw() {
background(0);
circle(x,y,r);
// current circleX = past circleX + (Mouse variation,+-)
// mouse variationX= mouseX-circleX
// >> x=x+ ( (mouseX-x) );
// >> y=y+ ( (mouseY-y) );
// divided variation by a number (for instane: 20)
// = continuously add (1/20 * variation)
x=x+ ( (mouseX-x) / slow );
y=y+ ( (mouseY-y) / slow );
}