(PHP 7 >= 7.2.0, PHP 8)
imageopenpolygon — オープンポリゴンを描画する
$image
, array $points
, int $num_points
, int $color
) : bool代替のシグネチャ (PHP 8.0.0 以降)
$image
, array $points
, int $color
) : bool
imageopenpolygon() 関数は、
与えられた image
のオープンポリゴンを描画します。
imagepolygon() とは異なり、
始点と終点の間の線は描かれません。
image
imagecreatetruecolor() のような画像作成関数が返す画像リソース。
points
ポリゴンの点を含む配列:
points[0] | = x0 |
points[1] | = y0 |
points[2] | = x1 |
points[3] | = y1 |
num_points
全ての点の数。少なくとも3以上である必要があります。
代替のシグネチャ(PHP 8.0.0 以降) でこの引数が省略された場合、points
は偶数でなければいけません。また、
num_points
は
count($points)/2
であると仮定されます。
color
imagecolorallocate() で作成された色識別子。
成功した場合に true
を、失敗した場合に false
を返します。
例1 imageopenpolygon() の例
<?php
// 空の画像を生成します。
$image = imagecreatetruecolor(400, 300);
// 色をポリゴンに割り当てます。
$col_poly = imagecolorallocate($image, 255, 255, 255);
// ポリゴンを描画します。
imageopenpolygon($image, array(
0, 0,
100, 200,
300, 200
),
3,
$col_poly);
// 画像をブラウザに出力します。
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
上の例の出力は、 たとえば以下のようになります。