Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Java - OverCircle() Method

DZone's Guide to

Java - OverCircle() Method

·
Free Resource
Given a circle's x and y origins and diameter,
determine if the mouse is in it only works in 
Processing from Processing.org


boolean overCircle(int x, int y, int diameter) {
  float disX = x - mouseX;
  float disY = y - mouseY;
  if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) {
    return true;
  } else {
    return false;
  }
}
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}