• myeclipse控制台打印文字


    先来看看效果图:

    下面是代码:

    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, 14);
    AffineTransform at = new AffineTransform();
    FontRenderContext frc = new FontRenderContext(at, true, true);
    GlyphVector gv = font.createGlyphVector(frc, "苏兴海祝您:"); // 要显示的文字
    Shape shape = gv.getOutline(5, 22);
    int weith = 150;
    int height = 25;
    boolean[][] view = new boolean[weith][height];
    for (int i = 0; i < weith; i++)
    {
    for (int j = 0; j < height; j++)
    {
    if (shape.contains(i, j))
    {
    view[i][j] = true;
    } else
    {
    view[i][j] = false;
    }
    }
    }
    for (int j = 0; j < height; j++)
    {
    for (int i = 0; i < weith; i++)
    {
    if (view[i][j])
    {
    System.out.print("~");// 替换成你喜欢的图案
    } else
    {
    System.out.print(" ");
    }
    }
    System.out.println();
    }
    } catch (Exception e)
    {
    e.printStackTrace();
    }

    Font font = new Font("黑体", Font.PLAIN, 16);
    AffineTransform at = new AffineTransform();
    FontRenderContext frc = new FontRenderContext(at, true, true);
    GlyphVector gv1 = font.createGlyphVector(frc, "端午节快乐!!"); // 要显示的文字
    Shape shape1 = gv1.getOutline(2, 12);//上下两个图的距离
    int weith1 = 150;
    int height1 = 25;
    boolean[][] view1 = new boolean[weith1][height1];
    for (int i = 0; i < weith1; i++)
    {
    for (int j = 0; j < height1; j++)
    {
    if (shape1.contains(i, j))
    {
    view1[i][j] = true;
    } else
    {
    view1[i][j] = false;
    }
    }
    }
    for (int j = 0; j < height1; j++)
    {
    for (int i = 0; i < weith1; i++)
    {
    if (view1[i][j])
    {
    System.out.print("~");// 替换成你喜欢的图案
    } else
    {
    System.out.print(" ");
    }
    }
    System.out.println();
    }
    }

    }

  • 相关阅读:
    Oracle 分区索引
    linux中select网络通信
    AVL树,红黑树,B-B+树,Trie树原理和应用
    zoj1232Adventure of Super Mario(图上dp)
    怎样更改Linux中默认的openjdk为自己安装的JDK
    食用甜玉米:增进健康,老少皆宜
    设计模式【3】:抽象工厂【创建对象】
    centos 7 安装JDK (Linux安装jdk)
    微信支付v3开发(5) 扫码并输入金额支付
    微信支付v3开发(6) 收货地址共享接口
  • 原文地址:https://www.cnblogs.com/MissSu/p/6920159.html
Copyright © 2020-2023  润新知