"float cx, cy;
float arcRadius;
float startAngle, endAngle, rotation;
void setup() {
size(400, 400);
background(255);
cx = width / 2;
cy = height / 2;
arcRadius = 150;
}
void draw() {
background(255);
translate(cx, cy);
rotate(rotation);
// Calculate the angle between the mouse and the center of the arc
float angleToMouse = atan2(mouseY - cy, mouseX - cx);
// Calculate the distance from the mouse to the center of the arc
float d = dist(mouseX, mouseY, cx, cy);
// Check if the mouse is inside the arc by comparing the angle and distance
if (d <= arcRadius && angleToMouse >= startAngle && angleToMouse <= endAngle) {
fill(0, 255, 0); // Set fill color to green
} else {
fill(0); // Set fill color to black
}
noStroke(); // Remove stroke
arc(0, 0, arcRadius * 2, arcRadius * 2, startAngle, endAngle);
}
void mousePressed() {
// Generate new random values for the parameters
startAngle = random(TWO_PI);
endAngle = startAngle + random(TWO_PI);
rotation = random(TWO_PI);
}
"
I am just testing this code where I want to check if mouse is inside an arc for some reason this is not working I am not sure why. Thanks in advance for the help