Thursday, July 12, 2012

what is Use of Antialiasing in java?

This is a sweet one. If you're doing any graphics at all in Java 2, you can make it look a lot nicer with a single line of code. Consider the following paint() method:
public void paint(Graphics g) {
  g.drawLine(20, 20, 40, 140);
  g.fillOval(50, 110, 120, 60);
  g.setFont(new Font("Serif", Font.ITALIC, 36));
  g.drawString("Cellini", 40, 80);

I haven't even used any 2D API features here--it's just plain old AWT graphics stuff. Adding antialiasing is easy. Just add this line to the very top of the paint() method:


No comments:

Post a Comment