1、PHP繪制空心圓的函數:
imageellipse($image, $cx, $cy, $width, $height, $color)。
代碼如下:
$img = imagecreatetruecolor(600, 600);
$red = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 0, 0, $red);
$x = imagesx($img);
$y = imagesy($img);
for($i=0;$i<20;$i++){
imageellipse($img, mt_rand(0,$x), mt_rand(0,$y), 200, 200, imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)));
}
header('Content-type:image/jpeg');
imagejpeg($img);
效果圖如下:

2、PHP繪制實心圓圖像:
imagefilledellipse($image, $cx, $cy, $width, $height, $color)。
代碼如下:
$img = imagecreatetruecolor(600, 600);
$red = imagecolorallocate($img, 255, 0, 0);
imagefill($img, 0, 0, $red);
$x = imagesx($img);
$y = imagesy($img);
for($i=0;$i<40;$i++){
imagefilledellipse($img, mt_rand(0,$x), mt_rand(0,$y), 200, 200, imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)));
}
header('Content-type:image/jpeg');
imagejpeg($img);
效果圖如下:

3、PHP繪制圓弧線條:
imagearc($image, $cx, $cy, $width, $height, $start, $end, $color)。
注意:0度是3點鐘方向!
代碼如下:
$img = imagecreatetruecolor(600, 600);
$white = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 0, 0, $white);
imagearc($img, 300, 300, 100, 100, 0, 90, imagecolorallocate($img, 255, 0, 0));
header('Content-type:image/jpeg');
imagejpeg($img);
效果圖如下:

4、PHP繪制實心圓弧(餅狀圖):
imagefilledarc($image, $cx, $cy, $width, $height, $start, $end, $color, $style)。
代碼如下:
$img = imagecreate(600, 600);
imagefill($img, 0, 0, imagecolorallocate($img, 255, 255, 255));
imagefilledarc($img, 300, 300, 200, 200, 0, 90, imagecolorallocate($img, 255, 255, 0), IMG_ARC_PIE);
imagefilledarc($img, 300, 300, 200, 200, 90, 180, imagecolorallocate($img, 255, 0, 255), IMG_ARC_PIE);
imagefilledarc($img, 300, 300, 200, 200, 180, 360, imagecolorallocate($img, 0, 255, 255), IMG_ARC_PIE);
header('Content-type:image/jpeg');
imagejpeg($img);
效果圖如下:

5、小實例,繪制一個數據統計餅狀圖:
代碼如下:
$messageArry = array('百度'=>'200','阿里巴巴'=>'300','騰訊'=>'400','聯想'=>'230');
$img = imagecreate(600, 600);
imagefill($img, 0, 0, imagecolorallocate($img, 255, 255, 255));
$r1 = $r2 = $num = 0;
foreach($messageArry as $k=>$v){
$r1 = $num==0 ? 0 : $r2;
$r2 = $r1==0 ? ($v/array_sum($messageArry))*360 : ($v/array_sum($messageArry))*360+$r1;
$r2 = min(360,ceil($r2));
imagefilledarc($img, 300, 300, 200, 200, $r1, $r2, imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)), IMG_ARC_PIE);
$num+=1;
}
header('Content-type:image/jpeg');
imagejpeg($img);
效果圖如下:

- 0、php安裝
- 1、選擇PHP作為首選后端語言的原因
- 2、PHP基本語法
- 3、PHP中變量和常量的區別
- 4、PHP中單引號和雙引號的區別
- 5、PHP檢測數據類型的幾種方式
- 6、PHP數據類型轉換
- 7、return、break、continue的區別
- 8、PHP代碼重用
- 9、字符串移除或添加函數
- 10、PHP中字符串大小寫切換以及翻轉和加密
- 11、PHP字符串截取和截取函數
- 12、PHP字符串替換和比較函數
- 13、PHP字符串url解析和實體轉換
- 14、addslashes在預定義字符串前添加反斜杠
- 15、PHP中的數組基本概念
- 16、數組函數implode、explode、in_array、each、list
- 17、PHP數組函數(count、reset、end、next、current、key)
- 18、ZendStudio軟件破解安裝包免費下載
- 19、【圖文】ZendStudio漢化方法
- 20、數組函數in_array、array_search、array_change_key_case、array_chu
- 21、關閉PHP提示的方法(運行出現Notice : Use of undefined constant 的完美解決方案
- 22、PHP數組函數(array_diff_ukey、array_diff_uassoc、array_intersect
- 23、PHP數組函數(array_fill、array_filter、array_flip、array_key_exis
- 24、PHP數組去重及向前向后刪除元素的函數
- 25、PHP數組函數(array_map、array_walk、array_walk_recursive)
- 26、PHP數組函數(compact、extract)
- 27、PHP數組函數(array_merge、array_merge_recursive)
- 28、PHP數組函數(range、array_count_values、array_product)
- 29、PHP數組函數(array_reduce、array_slice、array_splice、array_sum)
- 30、PHP數組排序函數總結
- 31、PHP中面向對象的基本概念及定義對象的方法
- 32、PHP創建對象與構造函數
- 33、PHP對象的釋放
- 34、PHP面向對象的特性(抽象、封裝、繼承、多態)
- 35、PHP面向對象的public、private、protected之間的區別
- 36、PHP面向對象中的final和const的用法
- 37、PHP面向對象的static關鍵字
- 38、PHP中的單例模式
- 39、$this、self、parent詳解
- 40、PHP中面向對象的抽象類和抽象方法
- 41、PHP面向對象中的接口interface
- 42、PHP面向對象中的魔術方法
- 43、面向對象方法get_object_vars、is_subclass_of、interface_exists
- 44、PHP中的數學函數方法總結
- 45、PHP文件處理disk_total_space、disk_free_space、dirname、file_exis
- 46、PHP目錄操作rename和scandir
- 47、PHP操作目錄opendir、readdir、glob
- 48、PHP打開fopen、讀取fread、寫入文件fwrite
- 49、PHP文件處理file_get_contents、file_put_contents、fgetc、fgets、fg
- 50、PHP截取字符串出現亂碼的解決方法(UTF8和GBK)
- 51、PHP文件內容分頁操作,避免亂碼
- 52、PHP文件操作函數file、set_include_path、copy
- 53、PHP文件操作函數filemtime、filectime、fileatime、touch
- 54、PHP文件操作指針函數feof、ftell、fseek、rewind、fpassthru
- 55、PHP文件操作pathinfo、realpath、flock、tempnam、tmpfile
- 56、設置php.ini配置實現表單文件上傳流程
- 57、PHP將上傳到臨時文件夾的文件移動到服務器指定文件夾內
- 58、PHP+input表單實現多文件上傳
- 59、PHP通過超鏈接實現文件下載
- 60、發送header文件頭信息實現文件下載
- 61、PHP中的日期時間_時區時間戳函數使用
- 62、PHP操作COOKIE緩沖區影響COOKIE傳遞方式
- 63、PHP中SESSION定義、建立、刪除方式
- 64、PHP.INI配置文件中關于session的設置
- 65、HP中Session緩存的概念與用法
- 66、PHP自定義Session處理機制
- 67、通過MYSQL數據庫操作Session會話完整源碼類
- 68、PHP連接數據庫實現分頁代碼
- 69、HTTP緩存實現原理詳解
- 70、PHP連接數據庫實現搜索+分頁功能
- 71、PHP圖像處理之建立畫布填充顏色、打開不同圖像類型處理
- 72、PHP顏色或圖像填充及不同填充方式
- 73、PHP圖像處理之畫線&定義線樣式&寬度&風格&筆刷
- 74、PHP圖像處理:繪制色素及矩形圖
- 75、PHP圖像處理之畫圓、弧線、網站餅狀統計圖繪制
- 76、PHP圖像處理之繪制多邊行及文字繪制
- 77、PHP 圖像處理之獲得文字寬高屬性&圖片水印函數功能
- 78、PHP生成圖片驗證碼demo【OOP面向對象版本】
- 79、PHP圖像處理 圖像處理之處理文字及獲得文字尺寸屬性,imagecopymerge imagecop
- 80、替換用戶輸入的QQ表情
- 81、PHP封裝MYSQL數據庫操作類源碼
- 82、PHP與XML技術結合使用解析