Tedd's code for Drawing Rotated Text
- You will need a font for this operation. You can find the font here .
- Then create a font directory and put this font in it. You will need this font for the "Draw Text on an Image" Project next week.
- Then change "Tedd's World" to something else.
SLAVE CODE FOLLOWS
<?php // PHP slave script drawing rotated text
// === create background work area
// create a blank image that is 160 by 160 pixels in size
$image = imagecreatetruecolor(160, 160);
// set a color RGB (238, 238, 238), which is GRAY
$gray = imagecolorallocate($image, 238, 238, 238);
// fill the entire image
imagefilledrectangle($image, 0, 0, 160, 160, $gray);
// set the foreground RGB color for the text
// ( 0, 51, 102) is a DARK BLUE
$color = imagecolorallocate($image, 0, 51, 102);
$font = 'fonts/arial.ttf';
$str = "Tedd's World...";
// combine the background image with a rotated text using the following specs
// (image, font-size, angle-rotation, x-position, y-position, text-color, font-name, text)
imagettftext($image, 20, 45, 15, 150, $color, $font, $str);
// tell the server that a GIF image follows
header("Content-Type: image/gif");
// display the image
imagegif($image);
// destroy the image (i.e., releases memory)
imagedestroy($image);
?>