คำอธิบาย
ฟังก์ชัน imagefilledrectangle() ใช้วาดสี่เหลี่ยมผืนผ้าเติมสี
รูปแบบการใช้งาน (Syntax)
imagefilledrectangle($img, $x1, $y1, $x2, $y2, $color)
พารามิเตอร์
image
สร้างภาพว่างด้วย imagecreatetruecolor()x1
พิกัด x จุดที่ 1y1
พิกัด y จุดที่ 1x2
พิกัด x จุดที่ 2y2
พิกัด y จุดที่ 2color
สีที่ใช้เติม
ค่าที่คืนกลับ
ฟังก์ชัน imagefilledrectangle() คืนค่า TRUE เมื่อสำเร็จ หรือ FALSE เมื่อล้มเหลว
ตัวอย่าง
<?php
// สร้างภาพ
$img = imagecreatetruecolor(500, 300);
$color = imagecolorallocate($img, 0, 128, 128);
imagefilledrectangle($img, 30, 30, 470, 270, $color);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
?>
ผลลัพธ์
ภาพแสดงสี่เหลี่ยมผืนผ้าเติมสีบนพื้นหลัง