User Tools

Site Tools


wargroundscanberra:character_sheet

This is an old revision of the document!


Character Sheets

<?php
// Path to our font file
$font = 'oldeenglish.ttf';
$fontsize = 20;

// array of field names
$names = array(
"Player Name:",
"Character's Name:",
"Titles/Nicknames:",
" ",
"Race/Species:",
"Hair Colour:",
"Eye Colour:",
"Skin Colour:",
" ",
"Class & Tier:",
"School of Magic:");

// count number of field names
$numnames = count($names)-1;

// create a bounding box for the text
//$dims = imagettfbbox($fontsize, 0, $font, $quote);


$width = 530; // upper-right x minus upper-left x 
$height = 754; // lower-right y minus upper-right y

// Create image
$image = imagecreatetruecolor($width,$height);

// pick color for the background
$bgcolor = imagecolorallocate($image, 183, 179, 159);
// pick color for the text
$fontcolor = imagecolorallocate($image, 0, 0, 0);

// fill in the background with the background color
imagefilledrectangle($image, 0, 0, $width, $height, $bgcolor);

// x,y coords for imagettftext defines the baseline of the text: the lower-left corner
// so the x coord can stay as 0 but you have to add the font size to the y to simulate
// top left boundary so we can write the text within the boundary of the image
$x = 36; 
$y = 20;
for ($count=0;$count<=$numnames;$count++) {
	$y=$y+36;
	imagettftext($image, $fontsize, 0, $x, $y, $fontcolor, $font, $names[$count]);
};

// tell the browser that the content is an image
header('Content-type: image/png');
// output image to the browser
imagepng($image);

// delete the image resource 
imagedestroy($image);
?>
wargroundscanberra/character_sheet.1721009660.txt.gz · Last modified: 2024/07/14 19:14 by curufea