xxxxxxxxxx
46
let oDiam = 80;
let mDiam = 40;
let x0 = 80;
let y0 = 135;
let x1 = 345;
let y1 = 240;
let x2 = 355;
let y2 = 55;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(220, 10, 120);
fill(255);
stroke(0);
ellipse(x0, y0, oDiam);
ellipse(x1, y1, oDiam);
ellipse(x2, y2, oDiam);
let d0 = sqrt((mouseX - x0) ** 2 + (mouseY - y0) ** 2);
if (d0 < oDiam / 2 + mDiam / 2) {
fill(255, 0, 0);
}
let d1 = sqrt((mouseX - x1) ** 2 + (mouseY - y1) ** 2);
if (d1 < oDiam / 2 + mDiam / 2) {
fill(255, 0, 0);
}
let d2 = sqrt((mouseX - x2) ** 2 + (mouseY - y2) ** 2);
if (d2 < oDiam / 2 + mDiam / 2) {
fill(255, 0, 0);
}
ellipse(mouseX, mouseY, mDiam);
}