创建三位字体图片
来源:互联网 发布:刷机用什么软件好 编辑:程序博客网 时间:2024/05/02 16:07
package tom.draw;
import java.applet.Applet;
import java.awt.*;
public class Text3DApplet extends Applet implements Runnable {
Image image; // 绘制文字的Image对象
Graphics graphics; // 绘制文字的Graphics对象
Thread thread; // 显示三维文字线程
int width, height; // 显示宽度、高度
String message; // 显示信息
int fontSize; // 文字尺寸
Font font; // 字体
/* (non-Javadoc)
* @see java.applet.Applet#init()
*/
public void init() {
Dimension dim = getSize(); // 得到Applet的尺寸 Dimension类封装单个对象中组件的宽度和高度
width = dim.width; // 得到宽度
height = dim.height; // 得到高度
image = createImage(width, height); // 得到Image实例
graphics = image.getGraphics(); // 得到Grahpics实例
message = getParameter("text"); // 从HTML文件中得到显示信息
if (message == null) { // 如果信息为空
message = "三维文字"; // 设置默认信息
}
fontSize = 30; // 设置字体大小
}
/* (non-Javadoc)
* @see java.applet.Applet#start()
*/
public void start() {
if (thread == null) {
thread = new Thread(this); // 实例化线程
thread.start(); // 运行线程
}
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() { // 线程运行主体
while (thread != null) {
try {
Thread.sleep(50L); // 线程休眠
} catch (InterruptedException ex) {
}
repaint(); // 重绘屏幕
}
}
/* (non-Javadoc)
* @see java.awt.Container#update(java.awt.Graphics)
*/
public void update(Graphics g) {
font = new Font("华文行楷", 1, fontSize); // 得到字体实例
graphics.setFont(font); // 设置显示字体
int j = (int) (255 * Math.random()); // 变量,用于生成渐变颜色
int k = (int) (255 * Math.random());
int l = (int) (255 * Math.random());
try {
Thread.sleep(2000); // 线程休眠
} catch (InterruptedException ex) {
}
graphics.setColor(Color.orange); // 设置当前颜色
graphics.fillRect(0, 0, width, height); // 填充背景
for (int i = 0; i < 6; i++) { // 三维深度
graphics.setColor( // 设置渐变颜色
new Color(255 - ((255 - j) * i) / 10,
255 - ((255 - k) * i) / 10,
255 - ((255 - l) * i) / 10));
graphics.drawString(message, 15 - i, height - 15 - i); // 绘制字符串
}
g.drawImage(image, 0, 0, this); // 绘制Image到屏幕
}
/* (non-Javadoc)
* @see java.awt.Container#paint(java.awt.Graphics)
*/
public void paint(Graphics g) {
update(g);
}
}
- 创建三位字体图片
- 字体创建
- 创建字体
- 根据字体文件创建字体
- 自动生成字体图片
- 关于图片字体化
- Android图片转换字体
- Android 字体图片设置
- 点阵字体的创建
- 通过路径创建字体
- 创建字体CreateFont,CreateFontIndirect
- VC 字体创建
- vc 字体的创建
- MFC 创建字体对话框
- 快速创建特殊字体
- 创建特殊字体
- 创建旋转特殊字体
- NGUI创建动态字体
- Strategies for Self Introduction in an Interview
- ASP.NET中上传下载文件
- Flex3+tomcat6.0+eclipse3.3环境配置
- 百度知道里面的爆笑问答
- 什么是备份数据库?什么是数据库一致性备份和非一致性备份?
- 创建三位字体图片
- Jquery选择器
- T-SQL查询语句(三):多表查询
- 段描述符高速缓冲寄存器
- Linux From Scratch 构建临时编译环境(一)
- 收藏几个strut2问题
- Dojo 1.2 Candidate 发布
- TrewView+Frame框架效果
- 打开控制台窗口以显示调试信息