While I was looking at the post counter in your sig I noticed that the post count appeared above an image rather than a single-colour background. I've been trying to work out how to do that for aaaages! Would you mind suggesting how I might add this capability to my current text-rendering code (found at the bottom of this post)?
LS97
Last edited by sparks (2011-07-25 17:12:07)
Offline
Sorry I didn't reply to my thread but the Scratch server failed on me yesterday. I read the post though, so here is the part of my source code you're asking for:
// create the background -- bg.png is my background
$img = imagecreatefrompng("bg.png");
//chooses the text color
$text_colour = imagecolorallocate( $img, 146, 208, 80 );
// get the font -- it's a truetype font, you probably need that as opposed to a bitmap font
$font = realpath('font.ttf');
// print the number of posts text
imagettftext($img, 13, 0, 15, 35, $text_colour, $font, $posts);
// tell browser about content type
header( 'Content-type: image/png' );
// create image
imagepng( $img );
this code should work by itself, although I haven't tested it. The comments contain the explanations
Offline
Thanks! I suppose I can seperate it from the standard on-colour background using a
if(isset($_GET['bgimage'])){
your code;
}
if(!isset($_GET['bgimage'])){
current image drawing code;
}Have you worked out how to set fonts, by the way? I can only change the size of what I can only assume is the default font
Offline
Getting on the car right now. See you some other time when I have internet again. And no I havent, and that should (in theory) work!
Offline
I already have the Trebuchet_MS.ttf font used by the Scratch fora and have a bookmarked font site, but thanks all the same fg123 (wow your name is fast to type! fg123, fg123, fg123. Takes maybe under a second to flick your finger across the f and g then flick from 1 to 3
fg123, love it! fg123
)
Offline
sparks wrote:
I already have the Trebuchet_MS.ttf font used by the Scratch fora and have a bookmarked font site, but thanks all the same fg123 (wow your name is fast to type! fg123, fg123, fg123. Takes maybe under a second to flick your finger across the f and g then flick from 1 to 3
fg123, love it! fg123
)
lol it is! fg123
OFF TOPIC! - oops
sparks I replied on that 3d thing
Last edited by RUMCHEERYPOOPOO (2011-07-26 06:04:24)
Offline