利用php创建打印文字动画效果
浏览:2883次 出处信息
利用php创建打印文字动画效果
用php+imagick+imagemagick实现的代码如下,在ubuntu下如何安装使用imagick+imagemagick,可以看这篇文章,其他操作系统请google相关文章
效果图片如下:
源代码:
以下是代码片段:
< ?php
/**
* 打印机打印效果
* @ param $text String 需要打印的文字
* @ param $color color|#16进制颜色
* @ param $fontsize int 字体大小
**/
function gif_print($text,$color=’red’,$fontsize = 40)
{
$ani = new Imagick();
$ani->setFormat(’gif’);
$textcolor = new ImagickPixel($color);
$bgcolor = new ImagickPixel(’white’);
//定义画笔
$draw = new ImagickDraw();
$draw->setFontSize($fontsize);
$draw->setFillColor($textcolor);
$draw->setGravity(imagick::GRAVITY_WEST);
//获取画笔写字的属性
$fontprop = $ani->queryFontMetrics($draw,$text);
$width = (int)$fontprop[’textWidth’] + 8;
$height = (int)$fontprop[’textHeight’] ;
//创建打印机的待机效果
$ani->newImage($width,$height,$bgcolor);
$draw->line(3,8,3,$height);
$ani->drawimage($draw);
$ani->setImageDelay(30);
$ani->newImage($width,$height,$bgcolor);
$ani->setImageDelay(30);
$ani->newImage($width,$height,$bgcolor);
$ani->drawimage($draw);
$ani->setImageDelay(30);
$textstrlen = strlen($text);
//创建打印机打印效果
for($i = 0;$i < = $textstrlen;$i++)
{
$single = substr($text,0,$i);
$ani->newImage($width,$height,$bgcolor);
$ani->setGravity(imagick::GRAVITY_WEST);
$ani->annotateImage($draw,0,0,0,$single);
$ani->setImageDelay(20);
}
header("Content-Type:image/gif");
echo $ani->getImagesBlob();
}
gif_print(’Welcome to Paitoubing.cn’,’blue’,30);
建议继续学习:
- jQuery Color Animations颜色动画插件 (阅读:7231)
- css3-animation制作逐帧动画 (阅读:5495)
- 通过php+imagick 创建PDF图片预览 (阅读:4033)
- 解决jQuery动画在chrome下暴走的问题 (阅读:3302)
- jQuery中的动画 (阅读:3011)
- 闲谈CSS3动画 (阅读:2806)
- 完美实现GIF动画缩略图 (阅读:2921)
- CSS3 动画系列 (阅读:2616)
- 对比Imagick和Gmagick的像素迭代功能 (阅读:2565)
- ReactNative Animated动画详解 (阅读:3145)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
<< 前一篇:利用php创建水中倒影的图片效果
后一篇:php 多版本共存时的注意事项 >>
文章信息
- 作者:排头兵 来源: 排头兵-互联网开发实践
- 标签: imagick 动画
- 发布时间:2010-03-08 23:10:38
建议继续学习
近3天十大热文
-
[84] memory prefetch浅析
-
[53] 基本排序算法的PHP实现
-
[52] 深入浅出cassandra 4 数据一致性问
-
[50] 转载:cassandra读写性能原理分析
-
[45] 字符引用和空白字符
-
[42] MySQL半同步存在的问题
-
[41] 获取Dom元素的X/Y坐标
-
[40] javascript插入样式
-
[40] Inline Form Labels
-
[38] JS中如何判断字符串类型的数字