ITeye博客

点阵输出字符

jslfl · 2013-02-06 13:38 · java编程 · 编程语言 · Markdown

http://www.oschina.net/code/snippet_113917_4627

import java.awt.Font; import java.awt.Shape; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform;

public class Test { public static void main(String args) { try { Font font = new Font("黑体", Font.PLAIN, 30); AffineTransform at = new AffineTransform(); FontRenderContext frc = new FontRenderContext(at, true, true); GlyphVector gv = font.createGlyphVector(frc, "JinCeon"); // 要显示的文字 Shape shape = gv.getOutline(5, 30); int weith = 200; int height = 40; boolean view = new boolean; for (int i = 0; i < weith; i++) { for (int j = 0; j < height; j++) { if (shape.contains(i, j)) { view* = true; } else { view* = false; } } } for (int j = 0; j < height; j++) { for (int i = 0; i < weith; i++) { if (view*) { System.out.print("@");// 替换成你喜欢的图案 } else { System.out.print(" "); } } System.out.println(); } } catch (Exception e) { e.printStackTrace(); } } }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。