Evan's Code for Drawing Rotated Text
- You will need a font for this operation. You can find the font here.
- Create a font directory and put the font in it.
- Then change "Evan's World" to something else.
CODE FOLLOWS
<?php
include('includes/header.php');
error_reporting(E_ALL);
$self = basename(__FILE__);
?>
<h1>Evan's Code for Drawing Rotated Text</h1>
<!-- Show the generated image -->
<img src="rotated-text.php" alt="Rotated Text">
<br><br>
<ul>
<li>You will need a font for this operation. You can find the font
<a href="fonts/arial.ttf">here</a>.
</li>
<li>Create a font directory and put the font in it.</li>
<li>Then change "Evan's World" to something else.</li>
</ul>
<hr><br>
CODE FOLLOWS
<br><br>
<?php
highlight_file($self);
echo "<hr><br>SLAVE CODE FOLLOWS<br><br>";
highlight_file('rotated-text.php');
include('includes/footer.php');
?>
SLAVE CODE FOLLOWS
<?php
// === 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 = "Evan's World...";
// draw rotated 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
imagedestroy($image);
?>