php画图实例_PHP

WBOY
Release: 2016-05-31 19:28:17
Original
1365 people have browsed it

本文实例讲述了php画图的方法。分享给大家供大家参考。具体实现方法如下:

代码如下:

// by MoreWindows
$imgWidth = 600; 
$imgHeight = 400; 
$img = imagecreatetruecolor($imgWidth, $imgHeight); 
imagefill($img, 0, 0, imagecolorallocate($img, 240, 240, 240));//设置底色 
$snowflake_size = 30; 
$font_file = "c:\\WINDOWS\\Fonts\\simhei.ttf";  
//生成大雪花 其实就是调用imagettftext()输出*号 
for ($i=1; $i { 
    $font_color = imagecolorallocate($img, mt_rand(100,200), mt_rand(100,200), mt_rand(100,200)); 
    imagettftext($img, $snowflake_size, mt_rand(0, 180), mt_rand(0, $imgWidth),mt_rand(0, $imgHeight), $font_color, $font_file, "□");  

//水印文字 
$black_color = imagecolorallocate($img, 0, 0, 0); 
imagettftext($img, 12, 0, $imgWidth - 50 , $imgHeight - 20, $black_color, $font_file, "PHP画图"); 
imagepng($img); 
imagedestroy($img); 
?>

本实例运行效果如下图所示

更多请参考:
http://www.php.net/manual/zh/refs.utilspec.image.php

希望本文所述对大家的PHP程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!