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

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


ฟังก์ชัน imagecolorclosesthwb() หา index ของสีที่มี Hue, Whiteness, Blackness ใกล้เคียงที่สุด

ไวยากรณ์

imagecolorclosesthwb($img, $red, $green, $blue)

พารามิเตอร์

  • img: ภาพจาก imagecreatetruecolor()
  • red: สีแดง
  • green: สีเขียว
  • blue: สีน้ำเงิน

คืนค่า

Integer index ของสีที่ HWB ใกล้เคียงสุด

ตัวอย่าง

<?php 
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif'); 
echo 'HWB = '. imagecolorclosesthwb($img, 50, 110, 90); 
imagedestroy($img); 
?>

ผลลัพธ์

HWB = 87