...

View Full Version : ImageString



Pandabeer
03-09-2009, 11:52 PM
hey, how do i put my image string like this:



/
/
/
/

and not like this:


----------

Iszak
03-10-2009, 03:00 AM
Well, I presumed that you wanted each character to be on a new line? Yeah, okay so I whipped up this simple example for you.


<?php

$width = 250;
$height = 80;

$image = imagecreate($width, $height);

$background = imagecolorallocate($image, 255, 255, 255);
$textColor = imagecolorallocate($image, 0, 0, 255);

$string = 'Hello';
$length = strlen($string);

for ($i = 0; $i < $length; $i++)
{
// Where ($i* 15) - 15 is the rate at which it moves left
// Where ($width / 2) - is to start the decline from the middle

imagestring($image, 5, ($width / 2) - ($i * 15), $i * 15, $string[$i], $textColor);
}

header('Content-type: image/gif');

imagegif($image);
imagedestroy($image);


Also I did.. this


<?php

$image = imagecreate(250, 80);

$background = imagecolorallocate($image, 255, 255, 255);
$textColor = imagecolorallocate($image, 0, 0, 255);

$string = 'Hello';
$length = strlen($string);

for ($i = 0; $i < $length; $i++)
{
// Where ($length - $i) * 2 - is the padding from the left in spaces

$char = str_pad($string[$i], ($length - $i) * 2, ' ', STR_PAD_LEFT);

imagestring($image, 5, 0, $i * 15, $char, $textColor);
}

header('Content-type: image/gif');

imagegif($image);
imagedestroy($image);


I like the first method, it's a lot nicer, if you didn't notice by now - I like experimenting :P



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum