For the sake of completeness, here is an example for imagechar.
The base-image automatically adjusts to the size and the height of the given string. Using the rand()-function the y-position of each char is slightly varied with every loop-run. You can easily rewrite the script to use a randomly generated string - the one given here just serves as an example.
<?php
$string = '1 2 3 4 5 6 7 8 9 A B C D E F G';
$font_size = 5;
$width=imagefontwidth($font_size)*strlen($string);
$height=imagefontheight($font_size)*2;
$img = imagecreate($width,$height);
$bg = imagecolorallocate($img,225,225,225);
$black = imagecolorallocate($img,0,0,0);
$len=strlen($string);
for($i=0;$i<$len;$i++)
{
$xpos=$i*imagefontwidth($font_size);
$ypos=rand(0,imagefontheight($font_size));
imagechar($img,$font_size,$xpos,$ypos,$string,$black);
$string = substr($string,1);
}
header("Content-Type: image/gif");
imagegif($img);
imagedestroy($img);
?>
imagechar
(PHP 4, PHP 5)
imagechar — Σχεδιάστε έναν χαρακτήρα οριζοντίως
Περιγραφή
int imagechar
( resource $image
, int $font
, int $x
, int $y
, string $c
, int $color
)
Η imagechar() σχεδιάζει τον πρώτο χαρακτήρα της c στην εικόνα id με το πάνω αριστερό σημείο του να είναι στη θέση x ,y (η πάνω αριστερή γωνία της εικόνας είναι το 0, 0) με χρώμα color . Εάν η font είναι 1, 2, 3, 4 ή 5, χρησιμοποιείται μία ενσωματωμένη γραμματοσειρά (με μεγαλύτερα νούμερα να αντιστοιχούν σε μεγαλύτερους χαρακτήρες).
Ανατρέξτε επίσης στην imageloadfont().
imagechar
sw at profilschmiede dot de
20-Jun-2005 08:35
20-Jun-2005 08:35
