php動態產生餅圖代碼_PHP教程

來源:互聯網
上載者:User
*/
//建立映像
$image=imagecreatetruecolor(300,300);
//定義畫餅狀圖所需要的顏色
$white=imagecolorallocate($image, 0xff, 0xff, 0xff);
$gray=imagecolorallocate($image, 0xc0, 0xc0, 0xc0);
$darkgray=imagecolorallocate($image, 0x90, 0x90, 0x90);
$navy=imagecolorallocate($image, 0x00, 0x00, 0x80);
$darknavy=imagecolorallocate($image, 0x00, 0x00, 0x50);
$red=imagecolorallocate($image, 0xff, 0x00, 0x00);
$darkred=imagecolorallocate($image, 0x90, 0x00, 0x00);

/*
imagecolorallocate -- 為一幅映像分配顏色   說明   int imagecolorallocate ( resource image, int red, int green, int blue)   imagecolorallocate() 返回一個標識符,代表了由給定的 rgb 成分組成的顏色。image 參數是 imagecreate() 函數的傳回值。red,green 和 blue 分別是所需要的顏色的紅,綠,藍成分。這些參數是 0 到 255 的整數或者十六進位的 0x00 到 0xff。imagecolorallocate() 必須被調用以建立每一種用在 image 所代表的映像中的顏色。
*/
//畫圖
for($i=160;$i > 150; $i--)
{
imagefilledarc($image, 150, $i, 200, 80, 0, 45, $darknavy, img_arc_pie);
imagefilledarc($image, 150, $i, 200, 80, 45, 75 , $darkgray, img_arc_pie);
imagefilledarc($image, 150, $i, 200, 80, 75, 360 , $darkred, img_arc_pie);
}
imagefilledarc($image, 150, 150, 200, 80, 0, 45, $navy, img_arc_pie);
imagefilledarc($image, 150, 150, 200, 80, 45, 75 , $gray, img_arc_pie);
imagefilledarc($image, 150, 150, 200, 80, 75, 360 , $red, img_arc_pie);
header('content-type: image/png');
imagepng($image);
imagedestroy($image);
/*
imagefilledarc()函數,可以在畫出橢圓弧的同時,使用指定顏色對其進行填充。使用此函數的這種功能,就可以很簡單的畫出一個用於統計的餅狀圖。下面示範imagefilledarc()函數的使用方法

該代碼的執行結果22.8所示:
*/

//在圖片畫線條

//建立真彩色映像
$img=imagecreatetruecolor(300,300);
$white=imagecolorallocate($img,255,255,255);
$red=imagecolorallocate($img,255,0,0);
$green=imagecolorallocate($img,0,255,0);
//在映像上畫橢圓
imagefilledellips教程e($img,150,150,250,100,$red);
imagefilledellipse($img,150,150,100,250,$green);
//輸出映像
header("content-type: image/png");
imagepng($img);
//銷毀映像
imagedestroy($img);
/*
該代碼的執行結果22.9所示:
*/

http://www.bkjia.com/PHPjc/632996.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632996.htmlTechArticle*/ //建立映像 $image=imagecreatetruecolor(300,300); //定義畫餅狀圖所需要的顏色 $white=imagecolorallocate($image, 0xff, 0xff, 0xff); $gray=imagecolorallocate($image,...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.