xxxxxxxxxx
24
function setup() {
createCanvas(400, 400);
noFill();
}
function draw() {
background(220);
stroke(255, 0, 0);
ellipse(width / 2, height / 2, 32, 32);
stroke(0, 255, 0);
ellipse(mouseX, mouseY, 32, 32);
stroke(0, 0, 255);
line(width / 2, height / 2, mouseX, mouseY);
var angle = atan2(width / 2 - mouseX, height / 2 - mouseY);
//var angle = atan2(mouseX - width / 2, mouseY - height / 2);
var x = (width / 2) + 16 * sin(angle);
var y = (height / 2) + 16 * cos(angle);
stroke(255, 0, 255);
ellipse(x, y, 8, 8);
}