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

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

คำอธิบาย

ฟังก์ชัน imagefill() ใช้เติมสีในภาพ

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

imagefill($img, $x, $y, $color)

พารามิเตอร์

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

  • x
    พิกัด x ของจุดเริ่มต้น

  • y
    พิกัด y ของจุดเริ่มต้น

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

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

ฟังก์ชัน imagefill() คืนค่า TRUE เมื่อสำเร็จ หรือ FALSE เมื่อล้มเหลว

ตัวอย่าง

<?php
   $img = imagecreatetruecolor(400, 400);
   $color = imagecolorallocate($img, 190, 255, 120);
   imagefill($img, 0, 0, $color);
   header('Content-type: image/png');
   imagepng($img);
   imagedestroy($img);
?>

ผลลัพธ์

ภาพสี่เหลี่ยมเต็มไปด้วยสีที่กำหนด