php畫圖實例
- php語言
- 關注:2.98W次
本文實例講述了php畫圖的.方法。分享給大家供大家參考。具體實現方法如下:
複製代碼 代碼如下:<?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:";
//生成大雪花 其實就是調用imagettftext()輸出*號
for ($i=1; $i<=400; $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);
?>
本實例運行效果如下圖所示
php畫圖實例1
更多請參考:
希望本文所述對大家的PHP程序設計有所幫助。</p
- 文章版權屬於文章作者所有,轉載請註明 https://xuezhezhai.com/zh-mo/jsj/php/4egx2n.html