ฟังก์ชัน imagepolygon() วาดรูปหลายเหลี่ยม (Polygon) บนภาพ
ไวยากรณ์
bool imagepolygon($img, $points, $num_points, $color)
พารามิเตอร์
- $img: ภาพจาก imagecreatetruecolor()
- $points: Array ของ vertices (x1, y1, x2, y2, ...)
- $num_points: จำนวน vertices
- $color: สีจาก imagecolorallocate()
คืนค่า
TRUE สำเร็จ FALSE ล้มเหลว
ตัวอย่าง
<?php
$img = imagecreatetruecolor(400, 300);
$color = imagecolorallocate($img, 120, 160, 190);
$bgcolor = imagecolorallocate($img, 10, 100, 50);
imagefill($img, 0, 0, $bgcolor);
imagepolygon($img, array(50, 50, 150, 200, 340, 200), 3, $color);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>
ผลลัพธ์
