imagepolygon
imagepolygon — 多角形を描画する
説明
bool imagepolygon ( resource image, array points, int num_points, int color )imagepolygon() は、指定した image に多角形を作成します。
パラメータ
- image
- imagecreatetruecolor()
のような画像作成関数が返す画像リソース。
- points
-
多角形の頂点からなる PHP の配列で、
points[0] = x0, points[1] = y0,
points[2] = x1, points[3] = y1 というようになります。
- num_points
-
頂点の総数。
- color
-
imagecolorallocate()
で作成した色 ID。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。例
例 939. imagepolygon() の例
<?php
// 空の画像を生成します
$image = imagecreatetruecolor(400, 300);
// 背景色を塗ります
$bg = imagecolorallocate($image, 0, 0, 0);
// 多角形の色を選択します
$col_poly = imagecolorallocate($image, 255, 255, 255);
// 多角形を描画します
imagepolygon($image, array (
0, 0,
100, 200,
300, 200
),
3,
$col_poly);
// 画像を出力します
header("Content-type: image/png");
imagepng($image);
?>
上の例の出力は、たとえば
以下のようになります。
参考
imagecreate() |
imagecreatetruecolor() |
固有名詞の分類
Weblioに収録されているすべての辞書からimagepolygonを検索する場合は、下記のリンクをクリックしてください。

- imagepolygonのページへのリンク