PDA

View Full Version : Display Clicks and level in Sig image


exdiogene
10-20-2009, 04:22 PM
Is there a way to Display Clicks and level in Sig image where it says "Click to feed me" etc...?

Seapyramid
10-20-2009, 05:01 PM
It is possible but as I don't use the text (it is hard on the server load) I can't advise you on it. I have removed it from Mystic Grove code. I am sure Brandon or Bloodrun could explain it to you.

BMR777
10-20-2009, 09:09 PM
This can be done by editing siggy.php. Look for these lines and edit:

$str1 = "Name: ".$name;
$str2 = "Owner: ".$owner;
$str3 = "Click Here to Feed Me!";
$str4 = "More Adopts at:";
$str5 = "www.".$domain;


imagestring ($image, 12, 0, $textheight, $str1, $color);
imagestring ($image, 12, 0, $textheight + 13, $str2, $color);
imagestring ($image, 12, 0, $textheight + 26, $str3, $color);
imagestring ($image, 12, 0, $textheight + 42, $str4, $color);
imagestring ($image, 12, 0, $textheight + 55, $str5, $color);

You can also call up the current level and number of clicks from the database and show it here. :)

exdiogene
10-21-2009, 11:22 AM
Thanks :) Done

gabeki
10-21-2009, 05:44 PM
is it possible to change the font of the text?

BMR777
10-21-2009, 05:48 PM
No, the actual font will just use whatever GD has as the default font. I haven't been able to get other fonts to work.

exdiogene
10-22-2009, 01:43 AM
You can use TTF fonts, im just trying to work out how you change the size :(#

For Example:

$font = imageloadfont("./fonts/yourfont.ttf");
imagestring ($image, 12, 0, $textheight, $str1, $font,$color);
imagestring ($image, 12, 0, $textheight + 13, $str2, $font, $color);
imagestring ($image, 12, 0, $textheight + 26, $str3, $font,$color);
imagestring ($image, 12, 0, $textheight + 42, $str6, $font,$color);
imagestring ($image, 12, 0, $textheight + 55, $str7, $font,$color);

Thenupload your font to a folder called fonts in your FTP :)

BMR777
10-22-2009, 05:13 PM
The 12's listed in each of the lines control the font size and the other numbers, such as 13, 26, etc control spacing between the lines. :)

exdiogene
10-23-2009, 03:59 AM
Yes but that only works for system fonts :P not ttf's. This is my problem. It wont change :(

gabeki
10-24-2009, 02:40 PM
ok, there's an error at the code, the '12' at "imagestring ($image, 12, 0, $textheight, $str1, $color)" is being referred to a built-in font.. but there are only 5 built-in fonts in php, so 12 is being used as font 5

the 12 is not the size of the font, if you change 12 to 5, you'll see the result is the same. the size (width and height) of the font (each char), is placed at the font file, in this case, in the 5th built-in font

if you want to use anotehr font, you can use

$font = imageloadfont("font place here");
imagestring ($image, $font, 0, $textheight, $str1, $color);

but the font must be .gdf

here's a windows converter from ttf to gdf
http://www.wedwick.com/wftopf.exe

but.. the fonts get pretty ugly anyway -_-
so I'm using that in my site:


$str1 = $name;
$str2 = "Level ".$currentlevel;

imagestring($image, 4, 2, $textheight + 1, $str1, $color);
imagestring($image, 4, 2, $textheight + 13, $str2, $color);


and I changed this part also

$newheight = $height + 18;

because my two strings occupy less space

thats it :D

- Edit -

oh, i found another thing

the $textheight determines where to place the first string of the text, it cames below the image, so this
$textheight = $width + 2;
is supposed to be
$textheight = $height + 2;

that way the text will not override the image in case the image has the width bigger than the height

exdiogene
10-24-2009, 02:55 PM
what do you mean the fonts get pretty ugly?

gabeki
10-24-2009, 03:02 PM
it gets kinda square x_x

--

here's another thing you can do..
since the level 0 of my adoptables are eggs, there's no pointing of showing 'level 0'
if($currentlevel == 0){
$str2 = "Help me Hatch!";
}

now I'm trying to resize the image x_x
if i change the newwidth, the image gets cropped, but I want to resize it, so all images are the same size independent of the adoptable... any ideas? '-'

- edit -

I found a way to do it :D
if someone wants to know...

you have to change this part:

ImageCopyResampled(
$img_temp,
$img_old,
0, 0, 0, 0,
$width,
$height,
$width,
$height
);

I wanted all my images to be 140 x 150 max (with text), so here's what I did

if($width < 140 AND height < 120){
$wresized = $width;
$hresized = $height;
}
else{
$div = $width / 140;
$wresized = $width / $div;
$hresized = $height / $div;

if($hresized > 120){
$div = $height / 120;
$wresized = $wresized / $div;
$hresized = $hresized / $div;
}
}

first verifies if the image is bigger than 140x120 (the text is 30 pixels height). if it is not, than the new WxH is the same of the original... if it is bigger, we resize it.. I used that $div so it will be resized and maintain the porpotion of the sides..

and you have to change those parts also

$newwidth = $wresized;
$newheight = $hresized + 30;

$img_temp = imagecreatetruecolor($newwidth, $newheight);

ImageCopyResampled(
$img_temp,
$img_old,
0, 0, 0, 0,
$wresized,
$hresized,
$width,
$height
);

$textheight = $hresized + 2;

johnreet
12-17-2010, 01:23 PM
It is possible, but since I did not use the text (it is difficult to load the server) I can not advise you on this. I removed the code Mystic Grove. I'm sure Brandon or Bloodrun could you explain it.