note 36697 deleted from function.imagettfbbox by sniper
| From: | sniper@php.net | Date: | Fri, 07 Nov 2003 12:41:51 +0000 |
| Subject: | note 36697 deleted from function.imagettfbbox by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-60085@lists.php.net to get a copy of this message | ||
Note Submitter: john@kiddco.net
----
Ok,
I got my script so far but i been trying to add positioning text so i can put it anywhere on the
business card.
Code:
<?php
error_reporting(E_ALL);
$fields = array(array('Company Name: ', 'company', 20, array(0, 0, 0)),
array('Company Message: ', 'message', 17, array(64, 128, 208)), array('Full
Name: ', 'name', 20, array(255, 255, 255)), array('Job Title: ',
'title', 16, array(255, 255, 255)), array('Address Line 1: ', 'line1',
17, array(255, 255, 255)), array('Address Line 2: ', 'line2', 17, array(255,
255, 255)), array('Address Line 3: ', 'line3', 17, array(255, 255, 255)),
array('Phone / Other: ', 'phone', 17, array(255, 255, 255)), array('Fax /
Other: ', 'fax', 17, array(255, 255, 255)), array('E-mail / Other: ',
'email', 17, array(255, 255, 255)), array('Web / Other: ', 'web', 17,
array(255, 255, 255)));
function input($text, $name)
{
echo $text, '<input type="text" name="', $name, '"
value="';
if(isset($_SESSION[$name]))
echo $_SESSION[$name];
echo '" />', "\n";
}
function drawstring($string, $diff, &$y, $font, $size, $color, $align = 'right')
{
global $image;
if(is_int($font))
{
$x = $diff;
for($i = 1; $i < strlen($string); ++$i)
{
imagechar($image, $font, $x, $y, $string{$i}, $color);
$x += imagefontwidth($font);
}
$y += imagefontheight($font);
}
else
{
$arr = imagettfbbox($size, 0, $font, $string); //left
//////////////////////////////////
$width = $arr[2] - $arr[0];
switch($align)
{
case 'right':
$x = imagesx($image) - $width - $diff;
break;
case 'center':
$x = imagesx($image) / 2 - ($width / 2);
break;
case 'left':
default:
$x = $diff;
break;
}
imagettftext($image, $size, 0, $x, $y + ($arr[1] - $arr[7]), $color, $font, $string);
$y += $arr[1] - $arr[7] + 1;
}
}
session_start();
if(isset($_GET['image']))
{
$colors = array();
$image = imagecreatetruecolor(510, 295);
$white = imagecolorallocate($image, 255, 255, 255);
$im = imagecreatefrompng('backgrounds/' . $_SESSION['img'] .
'.png');
imagecopy($image, $im, 0, 0, 0, 0, 510, 295);
$y = 90; //Top
=============================================
Had to cut some off