This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Circle looks bad Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Circle looks bad" Watch "Circle looks bad" New topic
Author

Circle looks bad

Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
I'm trying to draw a good looking circle with fillOval(0,0,12,12) but it looks quite bad.
It looks more like a rounded rectangle with little points sticking out.
Even the "Instant Graemlins" in this message board look more circular.
Am I doing something wrong or is this a limitation?
Drew
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
hi,
i think you should use antialising for smoother edges.
sample1
sample2
(this are the first google results, keywords "java antialiasing")
good luck
kay
raj madhuram
Ranch Hand

Joined: Oct 10, 2001
Posts: 71
Hi,
It sure looks like a circle to me at 12x12. Maybe if you go smaller, it looks like a rounded rectangle.
One way to make the circle look real smooth is to use anti-aliasing. Refer to the code attached. One shows a circle w/o anti-aliasing and the other with it.
Hope that helps.
regards,
Raj
Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
Thanks for the suggestions, but I forgot to mention that I need this to work with Java 1.1, thus no Graphics 2D or Swing...
Drew
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Well, then you'll have to fake antialiasing yourself... The following code doesn't do perfect antialiasing, but it should give you an idea of what to do...



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
Thanks Nate, that does look a lot better.
Although, I can still get a better looking circle in Photoshop.
I might just load a transparent gif of a circle instead...
Drew
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Circle looks bad
 
Similar Threads
Button Design.
WA #1.....word association
WA #2 ..... word association
How to design this part?
Casting a extended class