This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-07-25 17:09:24

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

LS97 please read!

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 http://www.blocks.scratchr.org/API.php?action=onlinestatus&user=LS97

Last edited by sparks (2011-07-25 17:12:07)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#2 2011-07-26 04:45:28

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: LS97 please read!

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

 

#3 2011-07-26 04:55:42

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: LS97 please read!

Thanks! I suppose I can seperate it from the standard on-colour background using a

Code:

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  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#4 2011-07-26 04:59:22

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: LS97 please read!

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!  smile

Offline

 

#5 2011-07-26 05:43:22

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: LS97 please read!

I think if you google PHP FONTS it should come up with good results.  smile


Hai.

Offline

 

#6 2011-07-26 05:56:10

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: LS97 please read!

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  tongue  fg123, love it! fg123  big_smile  )


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#7 2011-07-26 06:04:01

RUMCHEERYPOOPOO
Scratcher
Registered: 2008-12-23
Posts: 100+

Re: LS97 please read!

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  tongue  fg123, love it! fg123  big_smile  )

lol it is! fg123

OFF TOPIC! - oops

sparks I replied on that 3d thing

Last edited by RUMCHEERYPOOPOO (2011-07-26 06:04:24)


I AM ROOKWOOD101 NOW! (just so you know)

Offline

 

Board footer