#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# top quadrant of a point in correlation to mouse

edited January 2014

Hey all, I am having a bit of a difficult time trying to measure the top/bottom quadrants of an ellipse in correlation to the mouse. So, if mouse positions are on top quadrant, do this, else, do that.

``````float fishX;
float fishY;
float theta;
float x;
float y;

void setup() {
size(640, 360);
noStroke();
x = mouseX;
y = mouseY;
fishX =width/2;
fishY = height/2;

}

void draw() {
background(255);

if(radius <= 100 && theta > 0 && theta < PI){

println("INSIDE");
background(0,0, 255);

}

else if ( radius > 100 || theta > PI && theta < TWO_PI){

println ("OUTSIDE");
background(0,255,0);

}
fill(255,0,0);
ellipse(fishX, fishY, 30,30);

}
``````
Tagged:

• edited January 2014 Answer ✓

I think this is what you want ...

``````float x;
float y;

void setup() {
size(640, 360);
noStroke();
x = width/2;
y = height/2;
}

void draw() {

if ( dist(mouseX, mouseY, x, y)<radius &&  mouseY < y) {
println("TOP");
background(0, 0, 255);
}
else if ( dist(mouseX, mouseY, x, y)<radius &&  mouseY > y) {
println("BOTTOM");
background(255, 0, 255);
}
else {
background(-1);
}

fill(255, 0, 0);