# Ovals with the same X coordinate and different radiuses

• 12-15-2009, 09:33 PM
veseo
Ovals with the same X coordinate and different radiuses
Hello all, I have a newbie question. Why does the following code:

Code:

```g.fillOval(100, 100, 50, 50); g.fillOval(100, 175, 100, 100);```
not draw two circles one below the other, but the above one is situated a little bit to the left (you can see in the link below an example)? If I set radiuses the same, there's no problems, but if they are different - that problem occurs. That even occurs on a newly created Applet, so I don't think the rest of the code matters. What causes this and how could I prevent this?

*ttp://img260.imageshack.us/i/fuckt.png/
• 12-15-2009, 09:55 PM
Fubarable
I'm not clear on what your current problem is. Could you describe it a little better?

Imageshack - fuckt

Code:

```        // creates a circle centered at (125, 125) with radius of 25         g.fillOval(100, 100, 50, 50);                 // creates a circle centered at (150, 225) with radius of 50         g.fillOval(100, 175, 100, 100);```
• 12-15-2009, 10:15 PM
veseo
The problem was that I was thinking that the first oval would be centered at (100, 100) and the second one would be centered at (100, 175). So, the right formula is that the center of the oval is situated at( the first parameter(100) + 1/2 width; the second parameter(100) + 1/2 height). That clears it, and it shows I'm still way too newbie :(

Thanks, man :)
• 12-15-2009, 10:20 PM
Fubarable
No problem. To answer similar questions, your best bet is to check out the Java API, here the one for the Graphics class. There it will tell you exactly what Graphics#fillOval(...) does, and how the first two parameters define the upper left corner of the bounding rectangle, and the next two the width and height of the bounding rectangle.

Much luck!