畫一橢圓弧且填充

imagefilledarc

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagefilledarc — 畫一橢圓弧且填充

說明

imagefilledarc(
    resource $image,
    int $cx,
    int $cy,
    int $width,
    int $height,
    int $start,
    int $end,
    int $color,
    int $style
): bool

在指定的 image 上畫一橢圓弧且填充。

參數

image

由圖像建立函式(例如imagecreatetruecolor())返回的 GdImage 對象。

cx

中間的 x 座標。

cy

中間的 y 座標。

width

橢圓弧的寬度。

height

橢圓弧的高度。

start

起點角度。

end

終點角度。 0° is located at the three-o'clock position, and the arc is drawn clockwise.

color

imagecolorallocate() 建立的顏色識別符號。

style

值可以是下列值的按位或(OR):

  1. IMG_ARC_PIE
  2. IMG_ARC_CHORD
  3. IMG_ARC_NOFILL
  4. IMG_ARC_EDGED
IMG_ARC_PIE 和 IMG_ARC_CHORD 是互斥的;IMG_ARC_CHORD 只是用直線連線了起始和結束點,IMG_ARC_PIE 則產生圓形邊界。IMG_ARC_NOFILL 指明弧或弦只有輪廓,不填充。IMG_ARC_EDGED 指明用直線將起始和結束點與中心點相連,和 IMG_ARC_NOFILL 一起使用是畫餅狀圖輪廓的好方法(而不用填充)。

返回值

成功時返回 true, 或者在失敗時返回 false。

範例

示例 #1 建立一 3D 效果的餅狀圖

<?php

// 建立影象
$image = imagecreatetruecolor(100, 100);

// 分配一些顏色
$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);

// 建立 3D 效果
for ($i = 60; $i > 50; $i--) {
   
imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE);
   
imagefilledarc($image, 50, $i, 100, 50, 45, 75 , $darkgray, IMG_ARC_PIE);
   
imagefilledarc($image, 50, $i, 100, 50, 75, 360 , $darkred, IMG_ARC_PIE);
}

imagefilledarc($image, 50, 50, 100, 50, 0, 45, $navy, IMG_ARC_PIE);
imagefilledarc($image, 50, 50, 100, 50, 45, 75 , $gray, IMG_ARC_PIE);
imagefilledarc($image, 50, 50, 100, 50, 75, 360 , $red, IMG_ARC_PIE);


// 輸出影象
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

以上例程的輸出類似於:

例子輸出:建立一 3D 效果的餅狀圖

註釋

Leave a Reply

Your email address will not be published. Required fields are marked *