Home > Archive > PHP Language > September 2004 > Adding text to a graphic button
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Adding text to a graphic button
|
|
| l'atelier Ho 2004-09-07, 4:04 pm |
| Hello to all,
I have to write some scripts for a web side created with
Frontpage.
My customer used some button generated with FP.
He like that I use the same button in my php scripts. I
could save a lot of code and time if I could use only one
graphic button and then add the text on the fly.
My questions, it is possible to do that with PHP. ?
I should put about 20 buttons in a table something like
that:
¦---------¦
¦ Button1 ¦
¦---------¦
¦ Button2 ¦
¦---------¦
¦ Button3 ¦
¦---------¦
etc.
Many thanks in advance for your help.
Otto
| |
|
|
| Alvaro G Vicario 2004-09-08, 3:56 pm |
| *** Steve wrote/escribió (8 Sep 2004 02:02:51 -0700):
> See http://www.php.net/manual/en/ref.image.php
Just a remark: performance increases a great deal if you just generate
buttons once and store them in a folder, rather than doing it everything
they're loaded from a page.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
| |
| l'atelier Ho 2004-09-08, 3:56 pm |
| Many thanks four your quick answer.
I also think it will be faster if I can use a store image. My idee was to
use a stored image (the button) on only add the text on the fly.
I will look about the mentionned GD library, if it's possible do do that.
Regards
Otto
> *** Steve wrote/escribió (8 Sep 2004 02:02:51 -0700):
>
> Just a remark: performance increases a great deal if you just generate
> buttons once and store them in a folder, rather than doing it everything
> they're loaded from a page.
>
| |
| John Murtari 2004-09-09, 3:57 pm |
| l'atelier Ho <ateho@freesurf.ch> writes:
> Hello to all,
>
> I have to write some scripts for a web side created with
> Frontpage.
> My customer used some button generated with FP.
> He like that I use the same button in my php scripts. I
> could save a lot of code and time if I could use only one
> graphic button and then add the text on the fly.
>
> My questions, it is possible to do that with PHP. ?
> I should put about 20 buttons in a table something like
> that:
>
> ¦---------¦
> ¦ Button1 ¦
> ¦---------¦
> ¦ Button2 ¦
> ¦---------¦
> ¦ Button3 ¦
> ¦---------¦
> etc.
>
> Many thanks in advance for your help.
>
> Otto
>
If you would like to see a 'working' example of
some code using True Type fonts, see the stuff at
http://www.thebook-demo.com/php
--
John
________________________________________
___________________________
John Murtari Software Workshop Inc.
jmurtari@following domain 315.635-1968(x-211) "TheBook.Com" (TM)
http://thebook.com/
| |
|
| I have been experimenting with different ways of doing menus and here is
one of them that sounds like what you may be trying to do
http://ncug.net/index2.html
It doesn't actually use PHP to do anything ( it is an html ) and it is not
optimized yet; I need to use loops in the javascript mouse functions.
I used the same 3 images for all of the buttons (up, down, and clicked) and
then layered the text over the graphics. The text is 2 layers with the dark
layer above and to the left of the top layer of text to make it look more
like it is carved into the button. I need to tweak the fonts a little
better. I then layered a clear gif over the button and text thet reacts to
the mouseover and click. I probably could have just used a span there
instead of the transparent gif.
The fan at the bottom of the menu is made up of 3 gifs layered over each
other, the middle one being the animated frame. The fan rotation is kind of
jerky because I got tired of playing with it and just wanted to get it put
in, I'll make a better one when I get to it.
I have tested this in current versions of Netscape, IE, and Opera. One thing
I see that I need to get changed is the cursor needs to be "pointer" instead
of "hand" as hand does not give you a hand in Netscape and pointer does in
all 3 browsers.
This uses absolute positions for the components of the menu, but the menu as
a whole can be wrapped in a span if you need to move it.
I did a similar menu at http://www.oldenburggroup.com but there I used an
external .js file to control the button actions and some loops in php to
build the menu. The buttons there have the text on them, so there are 42
images being used.
"l'atelier Ho" <ateho@freesurf.ch> wrote in message
news:VA.00000268.02f5f7ac@freesurf.ch...
> Hello to all,
>
> I have to write some scripts for a web side created with
> Frontpage.
> My customer used some button generated with FP.
> He like that I use the same button in my php scripts. I
> could save a lot of code and time if I could use only one
> graphic button and then add the text on the fly.
>
> My questions, it is possible to do that with PHP. ?
> I should put about 20 buttons in a table something like
> that:
>
> ¦---------¦
> ¦ Button1 ¦
> ¦---------¦
> ¦ Button2 ¦
> ¦---------¦
> ¦ Button3 ¦
> ¦---------¦
> etc.
>
> Many thanks in advance for your help.
>
> Otto
>
| |
| l'atelier Ho 2004-09-21, 8:55 pm |
| In article <10l0jtipc7lev89@corp.supernews.com>, Arg wrote:
> Newsgroups: alt.comp.lang.php
> Subject: Re: Adding text to a graphic button
> Date: Tue, 21 Sep 2004 10:59:42 -0500
>
Hello Arg
I find the following solution:
I make the button with png8, you can also use GIF. The only
problem with GIF, some provider do not support it
(Licence!).
Write the following PHP script (button.php):
<?Php
Header("Content-type: images/png");
$im = imagecreatefrompng("$img");
$is = getimagesize("$img");
if(!isset($fs)) $fs=11;
$size =
imagettfbbox($fs,0,"$DOCUMENT_ROOT/fonts/$fn.ttf",$tx);
$black = ImageColorAllocate ($im, 0, 0, 0);
$dx = abs($size[2]-$size[0]);
$dy = abs($size[5]-$size[3]);
$xpad=$is[0];
$ypad=$is[1];
ImageTTFText($im, $fs, 0, ($xpad-$dx)/2, ($ypad+$dy)/2,
$black, "$DOCUMENT_ROOT/fonts/$fn.ttf", $tx);
Imagepng($im);
ImageDestroy($im);
?>
The script calculate the dimension of the picture and the
dimension of the text do display, then center them in x,y.
Include next the following link in your another scripts:
echo("<a href='$ref' target='$targ'>");
echo("<img border='0'
src='button.php?fn=arial&fs=$12&tx=Hello&img=button.png'>")
;
Place the necessary fonts in /fonts/ you can use windows
ttf fonts.
Regards
Otto
|
|
|
|
|