前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Java祝福生日快乐小程序

Java祝福生日快乐小程序

作者头像
用户7886150
修改2021-04-29 14:42:12
1.6K0
修改2021-04-29 14:42:12
举报
文章被收录于专栏:bit哲学院bit哲学院

参考链接: Java程序检查生日并打印生日快乐消息

public static void main(String[] args)

{

? ? BufferedImage image = new BufferedImage(200, 50, BufferedImage.TYPE_INT_ARGB);

? ? Graphics2D g = image.createGraphics();

? ? g.setFont(new Font("楷体", Font.BOLD, 30));

? ? g.drawString("生日快乐", 2, image.getHeight() - 20);

? ? int[] p = image.getRGB(0, 0, image.getWidth(), image.getHeight(), new int[image.getWidth() * image.getHeight()],

? ? ? ? ? ? 0, image.getWidth());

? ? char[] cs = { '生', '日', '快', '乐' };

? ? int ics = 0;

? ? for (int i = 0; i < image.getHeight(); i++) {

? ? ? ? for (int j = 0; j < image.getWidth(); j++) {

? ? ? ? ? ? int off = i * image.getWidth() + j;

? ? ? ? ? ? if (p[off] != 0) {

? ? ? ? ? ? ? ? System.out.print(cs[ics]);

? ? ? ? ? ? ? ? ics = (ics + 1) % 4;

? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? System.out.print(" ");

? ? ? ? ? ? }

? ? ? ? ? ? if (j == image.getWidth() - 1) {

? ? ? ? ? ? ? ? System.out.println();

? ? ? ? ? ? }

? ? ? ? }

? ? }

}

?转载自:https://blog.csdn.net/qq_43652327/article/details/102509206

本文系转载,前往查看

如有侵权,请联系?cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系?cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com