下一篇 » « 上一篇

Figure 17-1: GIF Button

作者:semirock    时间:2009-06-27    来源:http://444p.com    点击:4219    本文共1篇文章 字体:[ ]

Figure 17-1: GIF Button

<?
/*
** GIF button
** Creates a graphical button based
** form variables.
*/

//set parameters if not given
if(!isset($ButtonWidth))
{
$ButtonWidth = 100;
}

if(!isset($ButtonHeight))
{
$ButtonHeight = 30;
}

if(!isset($ButtonLabel))
{
$ButtonLabel = "CLICK";
}

if(!isset($ButtonFont))
{
$ButtonFont = 5;
}

//create image and colors
$image = imagecreate($ButtonWidth, $ButtonHeight);
$colorBody = imagecolorallocate($image, 0x99, 0x99, 0x99);
$colorShadow = imagecolorallocate($image, 0x33, 0x33, 0x33);
$colorHighlight = imagecolorallocate($image, 0xCC, 0xCC, 0xCC);

//create body of button
imagefilledrectangle($image,
1, 1, $ButtonWidth-2, $ButtonHeight-2,
$colorBody);


//draw bottom shadow www.444p.com php学习之家
imageline($image,
0, $ButtonHeight-1,
$ButtonWidth-1, $ButtonHeight-1,
$colorShadow);

//draw right shadow
imageline($image,
$ButtonWidth-1, 1,
$ButtonWidth-1, $ButtonHeight-1,
$colorShadow);


//draw top highlight
imageline($image,
0, 0,
$ButtonWidth-1, 0,
$colorHighlight);

//draw left highlight
imageline($image,
0, 0,
0, $ButtonHeight-2,
$colorHighlight);


//determine label size
$ButtonLabelHeight = imagefontheight($ButtonFont);
$ButtonLabelWidth = imagefontwidth($ButtonFont) *
strlen($ButtonLabel);

//determine label upper left corner
$ButtonLabelX = ($ButtonWidth - $ButtonLabelWidth)/2;
$ButtonLabelY = ($ButtonHeight - $ButtonLabelHeight)/2;


//draw label shadow
imagestring($image,
$ButtonFont,

www.444p.com


$ButtonLabelX+1,
$ButtonLabelY+1,
$ButtonLabel,
$colorShadow);

//draw label
imagestring($image,
$ButtonFont,
$ButtonLabelX,
$ButtonLabelY,
$ButtonLabel,
$colorHighlight);

//output image
header("Content-type: image/gif");
imagegif($image);
?>
责任编辑:semirock
发表评论
密码: (游客不需要密码)
记住我【Alt+S 或 Ctrl+Enter 快速提交】

搜索工具


热门搜索: [html][html][else][MYsql][mysql][调用][date][print][配置][配置]

《PHP函数》点击排行