1. Member
Join Date
Dec 2009
Posts
2
Rep Power
0

## Ovals with the same X coordinate and different radiuses

Hello all, I have a newbie question. Why does the following code:

Java 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/

2. I'm not clear on what your current problem is. Could you describe it a little better?

Imageshack - fuckt

Java 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);```
Last edited by Fubarable; 12-15-2009 at 10:00 PM.

3. Member
Join Date
Dec 2009
Posts
2
Rep Power
0
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 :)

4. 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!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•