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
https://forums.phpfreaks.com/topic/271440-php-gd-shadow-on-text-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.