php畫圖實(shí)例
本文實(shí)例講述了php畫圖的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
復(fù)制代碼 代碼如下:<?php
/pic/p>
$imgWidth = 600;
$imgHeight = 400;
$img = imagecreatetruecolor($imgWidth, $imgHeight);
imagefill($img, 0, 0, imagecolorallocate($img, 240, 240, 240));/pic/p>
$snowflake_size = 30;
$font_file = "c:WINDOWSFontssimhei.ttf";
/pic/p>
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, "□");
}
/pic/p>
$black_color = imagecolorallocate($img, 0, 0, 0);
imagettftext($img, 12, 0, $imgWidth - 50 , $imgHeight - 20, $black_color, $font_file, "PHP畫圖");
imagepng($img);
imagedestroy($img);
?>
本實(shí)例運(yùn)行效果如下圖所示
php畫圖實(shí)例1
更多請(qǐng)參考:
/pic/manual/zh/refs.utilspec.image.php
希望本文所述對(duì)大家的PHP程序設(shè)計(jì)有所幫助。</p
【php畫圖實(shí)例】相關(guān)文章:
PHP使用JPG生成GIF動(dòng)畫圖片實(shí)例10-27
PHP實(shí)用的代碼實(shí)例08-17
php查詢mysql的實(shí)例07-27
php簡(jiǎn)單偽靜態(tài)實(shí)例03-07
php防盜鏈實(shí)例11-06