(PHP 4, PHP 5, PHP 7, PHP 8)
imagechar — Draw a character horizontally
imagechar() draws the first character of
char
in the image identified by
image
with its upper-left at
x
,y
(top left is 0,
0) with the color color
.
image
Об'єкт GdImage, що повертається однією з функцій створення зображення, такою як imagecreatetruecolor().
font
Може бути 1, 2, 3, 4, 5 для вбудованих шрифтів в кодуванні latin2 (де більші числа відповідають більшим шрифтам) або примірником класу GdFont, що повертається функцією imageloadfont().
x
x-coordinate of the start.
y
y-coordinate of the start.
char
The character to draw.
color
Ідентифікатор кольору, створений за допомогою imagecolorallocate().
Версія | Опис |
---|---|
8.1.0 |
Параметром font тепер може бути як і примірник
GdFont, так і int. Раніше допускався тільки
int.
|
8.0.0 |
Тепер image має бути примірником
GdImage. Раніше очікувався
gd -resource.
|
Приклад #1 imagechar() example
<?php
$im = imagecreate(100, 100);
$string = 'PHP';
$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// prints a black "P" in the top left corner
imagechar($im, 1, 0, 0, $string, $black);
header('Content-type: image/png');
imagepng($im);
?>
Поданий вище приклад виведе щось схоже на: