wargroundscanberra:character_sheet
This is an old revision of the document!
Character Sheets
https://www.curufea.com/image.php
<?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;
$width = 530; // pixel size x of image
$height = 754; // size y of image
// 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; // increment by estimated line separation height
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);
?>
To do
- A form with default text for field names prefilled
- Images for the various bits
- Possibly API use for wherever photos get stored (or just upload them) - may need to edit photos to fit
- Variable sheet size - just scale everything to whatever is needed.
wargroundscanberra/character_sheet.1721010663.txt.gz · Last modified: by curufea
