How can I find the center of a circle drawn using Graphics.drawArc()?

John Zukowski

The drawArc() method has six arguments: the x and y coordinates of the top left corner, the width and height, as well as the start and ending angle positions. To get the center point, all you need is four of them. The width of the circle is from x to x+width-1. The height of the circle is from y to y+height-1. Thus, the center point would be x+(width-1)/2, y+(height-1)/2.

The minus one is necessary because a starting pixel is at x (or y). This is just like arrays where a 100 element array is indexed from 0 to 99.