wargroundscanberra:character_sheet
This is an old revision of the document!
Character Sheets
Go back to Wargrounds Canberra |
---|
Working Location: https://www.curufea.com/image.php
<?php // Character Sheet creator for Wargrounds Canberra // To be added- some images (to be sourced) as defaults - background, factions, space fillers and icons // To be added- a player photo (part of the form input) and basic text // Version 0.2 16/7/24 - curufea@yahoo.com // Currently hosted at www.curufea.com // Path to our font file (relative to the location of this file) $font = 'oldeenglish.ttf'; // Path to images (relative to the location of this file) $imagepath = 'data/media/wargroundscanberra/'; //defaults - to be overwritten by form inputs $fontsize = 20; $linespacing = round($fontsize*1.5); $width = 530; // pixel size x of image $height = 754; // size y of image // array of default field names $names = array( "Player Name:", "Character's Name:", "Titles/Nicknames:", "Race/Species:", "Hair Colour:", "Eye Colour:", "Skin Colour:", "Class & Tier:", "School of Magic:", "Faction:", "Warband:", "Marx:"); $factions = array( "clans", "empire", "greyscales", "horde", "wardens"); // count number of field names $numnames = count($names)-1; // Create image $image = imagecreatetruecolor($width,$height); // pick color for the background (off yellow - to be replaced with a texture image) $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 = $linespacing; $y = $fontsize; for ($count=0;$count<=$numnames;$count++) { $y=$y+$linespacing; // increment by estimated line separation height // Clunky bit to do positioning. I'll just generate an array next time if ($count==3||$count==7) $y=$y+$linespacing; // blank lines to separate if ($count==9) { // right column $y= $linespacing*5; $x= round($width/2); }; if ($count==$numnames) { // centre the last text in the right column $text = $names[$count] . " 999"; // add possible length $text_box = imagettfbbox($fontsize,0,$font,$text); // makes an array of co-ordinates for the text box // Get your Text Width and $text_width = $text_box[2]-$text_box[0]; $x = round(($width*2/3)-($text_width/2)); // middle of the right column minus half the size of the text $y=$y+$linespacing; }; // Field names in old english font 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.1721090399.txt.gz · Last modified: 2024/07/15 17:39 by curufea