(PHP 4, PHP 5, PHP 7, PHP 8)
imagecharup — 垂直繪製字元
$image
,$font
,$x
,$y
,$char
,$color
在指定的圖片上,以垂直方向在指定坐標繪製字元 char
。
image
一個 GdImage 物件,由其中一個圖片建立函式返回,例如 imagecreatetruecolor()。
font
可以是 1、2、3、4、5,表示 latin2 編碼的內建字體(數字越大,字體越大),或是由 imageloadfont() 返回的 GdFont 實例。
x
起始 x 坐標。
y
起始 y 坐標。
char
要繪製的字元。
color
使用 imagecolorallocate() 建立的顏色識別碼。
版本 | 說明 |
---|---|
8.1.0 | font 參數現在接受 GdFont 實例和 整數 (int);以前只接受 整數 (int)。 |
8.0.0 |
image 現在需要一個 GdImage 實例;以前需要一個有效的 gd 資源 (resource)。 |
範例 #1 imagecharup() 範例
<?php
$im = imagecreate(100, 100);
$string = '注意第一個字母是 N';
$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// 在白色背景上印出黑色的 "Z"
imagecharup($im, 3, 10, 10, $string, $black);
header('Content-type: image/png');
imagepng($im);
?>
上述範例將輸出類似以下的內容