imagefilledarc

(PHP 4 >= 4.0.6, PHP 5)

imagefilledarc -- 部分楕円を描画し、塗りつぶす

説明

int imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )

imagefilledarc() は、 imageで表したイメージに cx,cy (左上が0,0)を 中心とした部分楕円を描画します。wh はそれぞれ楕円の幅と高さを指定します。 また、開始点と終点は、引数sおよび eで度単位で指定されます。 style は次の選択肢のビット和です。

  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と共に指定することにより、 開始角と終端角は中心と結ばれます。これは、(塗りつぶすよりも) 「パイの切れ端」を縁どる良い方法です。

例 1. Creating a 3D looking pie

<?php

// this example is provided by poxy at klam dot is

// create image
$image = imagecreate(100, 100);

// allocate some solors
$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);

// make the 3D effect
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);


// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

注意: この関数はPHP 4.0.6で追加され、GD 2.0.1を必要とします。