I completed my like button, I'm not sure how to turn anti-aliasing off on the text though as it looks a little soft, I tried using negative values for the colour of the text like the php docs suggest but that completely ruins it.
look in my sig to see it \/\/
Offline
Great! Did you say you made on for this thread? Also, if you can work out how, try letting people customise the button appearance? So that can be the default but if someone wanted their like button to match their sig or something then they might appreciate being able to choose their own bg image and the text x,y and size?
Offline
sparks wrote:
Great! Did you say you made on for this thread? Also, if you can work out how, try letting people customise the button appearance? So that can be the default but if someone wanted their like button to match their sig or something then they might appreciate being able to choose their own bg image and the text x,y and size?
haha someone just suggested that on the thread for it So I think I'll add it to the todo list.
Offline
Just spotted unlike feature while adding it to the first post of this sig, I love it! Good job, Rum Are you planning to release it as open-source? I'm sure people could learn a lot from the code!
I for one would like to see how the return-redirect takes you back to the same place on a page!
Last edited by sparks (2011-07-27 13:18:54)
Offline
sparks wrote:
Just spotted unlike feature while adding it to the first post of this sig, I love it! Good job, Rum Are you planning to release it as open-source? I'm sure people could learn a lot from the code!
Sparks, have you EVER read the thread on it? I think not, ever since I released it at all I have put the source code on there, maybe you should read the it!
http://scratch.mit.edu/forums/viewtopic.php?id=69732
edit: it doesn't take you back to the same place on the page, at least I don't think so, all it does is take you back to the topic page that you just liked, no matter where you clicked the link so maybe it's your browser taking you to the right bit of the page.
Last edited by RUMCHEERYPOOPOO (2011-07-27 13:21:46)
Offline
Nice, rum! Great job!
and sparks, I fixed it. Just make sure the font has a relative php path -- no http!
preferably put it in the same directory. that's what i assmued with the code below:
<?PHP //parser in spaces $count = 1; $string = str_replace("_"," ",$_GET['string']); if(isset($_GET['bgimage']) && strstr($_GET['bgimage'], ".png")){ #thanks to LS97 for making most of the bgimage attribute! // create the background $img = imagecreatefrompng($_GET['bgimage']); //chooses the text color if(isset($_GET['textr']) | isset($_GET['textg']) | isset($_GET['textb'])){ $red = (int)$_GET['textr']; $green = (int)$_GET['textg']; $blue = (int)$_GET['textb']; $text_colour = imagecolorallocate($img, $red, $blue, $green); } else{ $text_colour = imagecolorallocate($img, 0, 0, 0); } // get the font $font = realpath('Trebuchet_MS.ttf'); // print the string imagettftext($img, 13, 0, 5, 20, $text_colour, $font, $string); // tell browser about content type header( 'Content-type: image/png' ); // create image imagepng( $img ); } if(!isset($_GET['bgimage'])){ // Set font size $font_size = 2; if(isset($_GET['font_size'])){ $font_size = $_GET['font_size']; } $font = '/fonts/Trebuchet_MS.ttf'; if(isset($_GET['font'])){ $font = $_GET['font']; } // Create image width dependant on width of the string $width = imagefontwidth($font_size)*strlen($string); if(isset($_GET['width'])){ $width = $_GET['width']; } // Set height to that of the font $height = imagefontheight($font_size); if(isset($_GET['height'])){ $height = $_GET['height']; } // Create the image pallette $img = imagecreate($width,$height); if(isset($_GET['bgr']) | isset($_GET['bgg']) | isset($_GET['bgb'])){ $red = (int)$_GET['bgr']; $blue = (int)$_GET['bgg']; $green = (int)$_GET['bgb']; $bg = imagecolorallocate($img, $red, $blue, $green); } else{ $bg = imagecolorallocate($img, 222, 223, 223); } // Font color if(isset($_GET['textr']) | isset($_GET['textg']) | isset($_GET['textb'])){ $red = (int)$_GET['textr']; $green = (int)$_GET['textg']; $blue = (int)$_GET['textb']; $color = imagecolorallocate($img, $red, $blue, $green); } else{ $color = imagecolorallocate($img, 0, 0, 0); } // Length of the string if(isset($_GET['limitstring'])){ if(strlen($string) > $_GET['limitstring']){ $string= substr($string, 0, $_GET['limitstring']); } } $len = strlen($string); // Y-coordinate of character, X changes, Y is static $ypos = 0; if(isset($_GET['ypos'])){ $ypos = $_GET['ypos']; } // Loop through the string for($i=0;$i<$len;$i++){ // Position of the character horizontally if(isset($_GET['xpos'])){ $xpos = $i * imagefontwidth($font_size) + $_GET['xpos']; } else{ $xpos = $i * imagefontwidth($font_size); } // Draw character imagechar($img, $font_size, $xpos, $ypos, $string, $color); // Remove character from string $string = substr($string, 1); } // Return the image header("Content-Type: image/gif"); imagegif($img); } // Remove image imagedestroy($img); ?>
Hope it works...
Last edited by LS97 (2011-07-27 13:33:36)
Offline
Just to prove it, try this:
http://mod-share.webuda.com/imgs/posts/ … ;string=hi
Offline
LS97 wrote:
Just to prove it, try this:
http://mod-share.webuda.com/imgs/posts/ … ;string=hi
Last edited by scimonster (2011-07-28 04:35:23)
Offline
What's an "I=Topic"?
And we have 16 pages in 9 days?
Offline
scimonster wrote:
What's an "I=Topic"?
And we have 16 pages in 9 days?
I wondered that...
Offline
In newest project links, you put the [img] tag instead of [url].
Offline
You also forgot to put in the bbcode on quite a few of the examples
We're just trying to make your topic better!
Offline
Yeah, I know, I was joking
aaaaaaand:
[img]http://blocks.scratchr.org/textrender.php?string=You%27d_better_believe_this_works_now!&bgimage=http://www.wastepapersolutions.co.uk/ESW/Images/bluesquare.png&xpos=15&ypos=150[/img]
Last edited by sparks (2011-07-28 05:06:55)
Offline
sparks wrote:
Yeah, I know, I was joking
aaaaaaand:
http://blocks.scratchr.org/textrender.p … p;ypos=150
Nice! has comp's API helper caught up with (y)our progress?
Offline
RUMCHEERYPOOPOO wrote:
I completed my like button, I'm not sure how to turn anti-aliasing off on the text though as it looks a little soft, I tried using negative values for the colour of the text like the php docs suggest but that completely ruins it.
look in my sig to see it \/\/
^^Read this please LS97
Offline
I don't think so, no, I've not seen him in a while!
Thanks so much for the help with that bgimage, it was slowly killing me It does not take different font sizes that I can tell but all the other parts of it are as customiseable as the non-image one
Offline
sparks wrote:
I don't think so, no, I've not seen him in a while!
Thanks so much for the help with that bgimage, it was slowly killing me It does not take different font sizes that I can tell but all the other parts of it are as customiseable as the non-image one
I think I'll take a look to see how far hes got and then try and finish it up
Offline
sparks wrote:
Well as far as I'm aware, the most recent one is the downloadable one in post #2...
Lol no offence to him but the code is a nightmare, I think I'll have to redo it at some point, although that is an outsiders opinion, I'm sure he understands it perfectly. It's just that some of the code needs changing completely.
Offline
A lot of programmers are self-taught so they just do what works. It's like when johnnydean1 would get a block to work using about 50 lines and then it turns out nXIII knew a commands to do exactly that and cut it down to three. You could always try and develop your own generator if you wanted to have a go?
Offline
sparks wrote:
A lot of programmers are self-taught so they just do what works. It's like when johnnydean1 would get a block to work using about 50 lines and then it turns out nXIII knew a commands to do exactly that and cut it down to three. You could always try and develop your own generator if you wanted to have a go?
I think I'll wait until I've cut down on the todo list for the like buttons a bit more, as it's quite a big job making a generator for it, and I commend what comp has done.
Offline