Jump to content

Php Gd (Shadow On Text) Help


Dexxt3r

Recommended Posts

I'm new to this type of thing, and really need some help i'm trying to place a Shadow on my text which is on a image.

 

I found this Shadow code in the Php Manuel

imagettftext:

 

 

<?php
// Set the content-type
header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

 

 

And this is my in my script:

 

 

$black = imagecolorallocate($img, R($htmlcolor), G($htmlcolor), B($htmlcolor));
/*
Here you can make the color that u like 
Examples:
$red = imagecolorallocate($img, 255, 0, 0);
$blue = imagecolorallocate($img, 0, 0, 255);
$yellow = imagecolorallocate($img, 255, 255, 0);
$green = imagecolorallocate($img, 0, 255, 0);
$black = imagecolorallocate($img, 0, 0, 0);
*/
//=========================================================

$con = ConnectServer($server_ip,$server_port);
if($con)
{
$dataNEW = GetData($con);
//echo $data['hostname'];
imagettftext($img, 10, 0, 8, 17, $black, $font, $dataNEW['hostname']);
imagettftext($img, 8, 0, 7, 40, $black, $font, "GameMode: ".$dataNEW['gamemode']);
imagettftext($img, 8, 0, 7, 55, $black, $font, "IP: ".$server_ip.":".$server_port);
imagettftext($img, 8, 0, 7, 70, $black, $font, "Players: ".$dataNEW['players']."/".$dataNEW['maxplayers']);
imagettftext($img, 8, 0, 7, 85, $black, $font, "Map: ".$dataNEW['mapname']);
imagepng($img);
}
else {
imagettftext($img, 8, 0, 150, 15, $black, $font,"This Server is offline...");
imagepng($img);
}
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.