imagefilledpolygon
(PHP 4, PHP 5, PHP 7, PHP 8)
imagefilledpolygon — 畫一多邊形並填充
說明
   imagefilledpolygon(
resource
array
int
int
): bool
  resource
$image,array
$points,int
$num_points,int
$color): bool
   imagefilledpolygon() 在 image
   影象中畫一個填充了的多邊形。
  
   points 參數是一個按順序包含有多邊形各頂點的
   x 和 y
   座標的陣列。
  
   num_points 參數是頂點的總數,必須大於 3。
  
示例 #1 imagefilledpolygon() 例子
<?php
// 建立多邊形各頂點座標的陣列
$values = array(
            40,  50,  // Point 1 (x, y)
            20,  240, // Point 2 (x, y)
            60,  60,  // Point 3 (x, y)
            240, 20,  // Point 4 (x, y)
            50,  40,  // Point 5 (x, y)
            10,  10   // Point 6 (x, y)
            );
// 建立影象
$image = imagecreatetruecolor(250, 250);
// 設定顏色
$bg   = imagecolorallocate($image, 200, 200, 200);
$blue = imagecolorallocate($image, 0, 0, 255);
// 畫一個多邊形
imagefilledpolygon($image, $values, 6, $blue);
// 輸出影象
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>