糯米文學吧

位置:首頁 > 計算機 > php語言

php畫圖實例

php語言3.12W

本文實例講述了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:";

//生成大雪花 其實就是調用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

標籤:PHP 畫圖 實例