I'm trying to achieve an effect of ASCII Art, but it is not working. The code is supposed to create "Visual Grammar" out of the letters "VG". There seem to be no errors and the output is displayed, but it only consists of a few rows of letters. It's not creating any image. Any idea what might have gone wrong?
package visualgrammar;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
public class Vg {
public static void main(String[] args) {
int width = 150;
int height = 30;
BufferedImage image = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
Graphics a = image.getGraphics();
a.setFont(new Font("SansSerif", Font.BOLD, 24));
Graphics2D a2 = (Graphics2D) a;
a2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
a2.drawString("VISUAL GRAMMAR", 10, 20);
for (int y = 0; y < height; y++) {
StringBuilder builder = new StringBuilder();
for (int x = 0; x < width; x++) {
builder.append(image.getRGB(x, y) == -16777216 ? "" : "V");
}
System.out.println(builder);
}
}
}