How to draw a decent looking Circle in Java

前端 未结 7 1393
我在风中等你
我在风中等你 2020-11-27 06:20

I have tried using the method drawOval with equal height and width but as the diameter increases the circle becomes worse looking. What can I do to have a decent looking cir

7条回答
  •  轮回少年
    2020-11-27 06:39

    Inability to draw a "decent looking circle" is related to the very old bug 6431487.

    Turning antialiasing on does not help a lot - just check the kind of "circle" produced by the drawOval() or drawShape(Eclipse) when the required circle size is 16 pixels (still pretty common for icon size) and antialiasing is on. Bigger antialiased circles will look better but they are still asymmetric, if somebody will care to look at them closely.

    It seems that to draw a "decent looking circle" one has to manually draw one. Without antialiasing it will be midpoint circle algorithm (this question has an answer with a pretty java code for it).

提交回复
热议问题