《PHP應用:php畫圖實例》要點:
本文介紹了PHP應用:php畫圖實例,希望對您有用。如果有疑問,可以聯系我們。
PHP學習本文實例講述了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:\\WINDOWS\\Fonts\\simhei.ttf";??
//生成大雪花 其實就是調用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學習本實例運行效果如下圖所示
PHP學習![PHP應用:php畫圖實例]()
PHP學習更多請參考:
http://www.php.net/manual/zh/refs.utilspec.image.php
PHP學習希望本文所述對大家的PHP程序設計有所贊助.
歡迎參與《PHP應用:php畫圖實例》討論,分享您的想法,維易PHP學院為您提供專業(yè)教程。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/14218.html