imagepolygon

(PHP 3, PHP 4, PHP 5)

imagepolygon -- 多角形の描画

説明

bool imagepolygon ( resource image, array points, int num_points, int color )

imagepolygon() は、画像 im 上に 多角形を生成します。 points は多角形の頂点からなる PHP の配列で、 points[0] = x0, points[1] = y0, points[2] = x1, points[3] = y1 という風になっています。 num_points は頂点の総数です。

例 1. 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() も参照ください。