Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน imagefilledrectangle() ใน PHP

คำอธิบาย

ฟังก์ชัน imagefilledrectangle() ใช้วาดสี่เหลี่ยมผืนผ้าเติมสี

รูปแบบการใช้งาน (Syntax)

imagefilledrectangle($img, $x1, $y1, $x2, $y2, $color)

พารามิเตอร์

  • image
    สร้างภาพว่างด้วย imagecreatetruecolor()

  • x1
    พิกัด x จุดที่ 1

  • y1
    พิกัด y จุดที่ 1

  • x2
    พิกัด x จุดที่ 2

  • y2
    พิกัด y จุดที่ 2

  • color
    สีที่ใช้เติม

ค่าที่คืนกลับ

ฟังก์ชัน 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);
?>

ผลลัพธ์

ภาพแสดงสี่เหลี่ยมผืนผ้าเติมสีบนพื้นหลัง