imagearc

(PHP 4, PHP 5, PHP 7)

imagearc部分楕円を描画する

説明

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

imagearc() は、指定した座標を中心とする円弧を描画します。

パラメータ

image

imagecreatetruecolor() のような画像作成関数が返す画像リソース。

cx

中心の x 座標。

cy

中心の y 座標。

width

円弧の幅。

height

円弧の高さ。

start

始点の角度。

end

終点の角度。 0° は 3 時の位置で、そこから時計回りの方向に円弧が描かれます。

color

imagecolorallocate() で作成された色識別子。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例1 imagearc() による円の描画

<?php

// 200*200 の画像を作成します
$img imagecreatetruecolor(200200);

// 色を設定します
$white imagecolorallocate($img255255255);
$red   imagecolorallocate($img255,   0,   0);
$green imagecolorallocate($img,   0255,   0);
$blue  imagecolorallocate($img,   0,   0255);

// 頭を描きます
imagearc($img100100200200,  0360$white);
// 口を描きます
imagearc($img10010015015025155$red);
// 左右の目を描きます
imagearc($img,  60,  75,  50,  50,  0360$green);
imagearc($img140,  75,  50,  50,  0360$blue);

// 画像をブラウザに出力します
header("Content-type: image/png");
imagepng($img);

// メモリを解放します
imagedestroy($img);

?>

上の例の出力は、 たとえば以下のようになります。

出力例 : imagearc() による円の描画

参考