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

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


ฟังก์ชัน imagecharup() วาดตัวอักษรแนวตั้ง (Vertical) บนภาพ

ไวยากรณ์

imagecharup(img, font, x, y, c, color)

พารามิเตอร์

  • img: ภาพจาก imagecreatetruecolor()
  • font: ขนาดฟอนต์ 1-5 (built-in latin2)
  • x: พิกัด X
  • y: พิกัด Y
  • c: ตัวอักษรที่จะวาด
  • color: Color identifier

คืนค่า

TRUE สำเร็จ FALSE ล้มเหลว

ตัวอย่าง

<?php 
$img = imagecreate(300, 300); 
$str = 'Demo'; 
$bg = imagecolorallocate($img, 190, 255, 255); 
$color = imagecolorallocate($img, 120, 60, 100); 
imagecharup($img, 5, 30, 50, $str, $color); 
header('Content-type: image/png'); 
imagepng($img); 
?>

ผลลัพธ์

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

ตัวอย่างที่ 2

<?php 
$img = imagecreate(270, 270); 
$str = 'Example'; 
$bg = imagecolorallocate($img, 160, 185, 175); 
$color = imagecolorallocate($img, 100, 120, 100); 
imagecharup($img, 10, 80, 100, $str, $color); 
header('Content-type: image/png'); 
imagepng($img); 
?>

ผลลัพธ์

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