Results 1 to 4 of 4
  1. #1
    veseo is offline Member
    Join Date
    Dec 2009
    Posts
    2
    Rep Power
    0

    Default 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. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

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

    For what it's worth, here's your link:
    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. #3
    veseo is offline Member
    Join Date
    Dec 2009
    Posts
    2
    Rep Power
    0

    Default

    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. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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!

Similar Threads

  1. weird location of ovals
    By diggitydoggz in forum New To Java
    Replies: 6
    Last Post: 12-24-2008, 01:25 AM
  2. Replies: 4
    Last Post: 12-17-2008, 06:57 PM
  3. Demonstration of drawing ovals in SWT
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 06-28-2008, 10:28 PM
  4. set coordinate to an image
    By nuur in forum AWT / Swing
    Replies: 2
    Last Post: 04-01-2008, 09:08 AM
  5. X&Y Coordinate Drawing on jPanel
    By BHCluster in forum Java 2D
    Replies: 2
    Last Post: 03-27-2008, 11:47 AM

Posting Permissions

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