先来看看效果图:

下面是代码:

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();
}
}

}

最新文章

  1. #ThinkPHP_3.2.2模型# where查询条件汇总
  2. C++ 编译器内存错误 after Normal block。。。
  3. linux c下mysql编程样例
  4. SharePoint 2013的HTML5特性之响应式布局
  5. TRIZ系列-创新原理-22-变害为利原理
  6. [css]《css揭秘》学习(四)-一个元素实现内圆角边框
  7. 模拟实现一个ATM+购物商城程序
  8. spring boot 文件上传大小限制
  9. 使用Spring Cloud连接不同服务
  10. 从MongoDB里面取得json格式的数据,然后存为本地的json文件,然后再从json读取变为dict
  11. Odoo Model内容详解
  12. STS或eclipse安装SVN插件
  13. django 常用字段类型
  14. 转 CentOS 7 minimal 版本安装后网络配置
  15. 基于zookeeper+mesos+marathon的docker集群管理平台
  16. Android开发大纲
  17. golang中使用mongodb
  18. SpringMVC+Hibernate 项目开发之一(Maven环境搭建)
  19. 标记编码报错ValueError: bad input shape ()
  20. memcached数据库

热门文章

  1. java线程池相关接口Executor和ExecutorService
  2. 133. Clone Graph (Graph, Map; DFS)
  3. ROS launch启动文件的理解与编写
  4. CentOS7下NFS服务安装及配置
  5. 查看linux服务器状态常用命令
  6. Android Studio真机测试失败-----&#39;&#39;No target device found&quot;
  7. Send [1] times, still failed
  8. Linux 基础教程 28-nc命令
  9. test4 结对项目
  10. 二段Linq Groupby操作