程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> 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); 
?>

本實例運行效果如下圖所示

更多請參考:
http://www.php.net/manual/zh/refs.utilspec.image.php

希望本文所述對大家的PHP程序設計有所幫助。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved