搜索
首页php教程php手册通过文字传递创建的图形按钮_php基础

通过文字传递创建的图形按钮,说明请看文内中文详细说明
    /* PHP3 按钮生成器,(c) 2000 by IzzySoft (izzysoft@buntspecht.de)
    * 许可证:GPL(如果您找到了它,请给我留言,我会很高兴)
    * 有用 - 如果您使用它的话。当然,我对
    * 您对脚本所做的增强非常感兴趣!
    *
    * 目的:生成带有通过参数传递的文本的按钮。
    *
    * 脚本的可能参数:
    *按钮 - 输入 gif 图像。
    *指定的图像文件应位于同一目录中     *此脚本所在的位置。
    *字体 - 使用的字体(1 - 5;1 非常小,3 中等,5 正常大小。
    *如果文本    *对于选定的尺寸来说太长。)默认值:5
    *文本 - 要放置在按钮上的文本
    *文本颜色 - 字母的颜色
。 *在此示例代码中仅定义了蓝色、白色和黑色;
    *但您可以轻松添加自定义颜色。
    *width,heigth - 按钮的宽度和高度。仅当目标
    *按钮的大小应与源图像不同时才有用。
    *
    * 使用示例:
    *

    * 将查找 Yellow.gif 并在其上添加字符串“Example”。 通过文字传递创建的图形按钮_php基础    *
    * 我通常生成三个按钮(一个显示选定的
    * 项目,一个用于 mouseover(),一个是默认按钮)。源
    * 图像是 Yellow.gif、white.gif 和 blue.gif - 所以我的脚本假设
    * blue.gif 作为默认值,如果“button=”未指定 - 您可能希望更改
    *下面这个,很简单;)
    */
    // ===========================[检查
//     r 参数和/或设置默认值 ]===
    if (($font == "") || ($font > 5) || ($font     if ($text == "") { $text="Moin!"; }// 按钮文本
    if ($textcolor == "") {// 字母颜色     switch ($button) {
    case "yellow":
    case "white":
    $textcolor = "黑色";
    休息;
    默认值:
    if ($button == "") { $button = "blue"; }
    $textcolor = "白色";
    休息;
    }
    } // 文本颜色结束
    $im_info = getimagesize("$button.gif"); // 按钮大小
    if ($width == "") {
    if ($im_info == "") {
    $buttonwidth = 125;
    } else {
    $buttonwidth = "$im_info[0]";
    }
    } else {
    $buttonwidth = $width;
    }
    if ($heigth == "") {
    if ($im_info == "") {
    $buttonheigth = 30;
    } else {
    $buttonheigth = "$im_info[1]";
    }
    } else {
    $buttonheigth = $heigth;
    }
    $vmidth = ceil($buttonheigth / 2);
    // =======================================
    //     === [ 现在让我们定义一些颜色 ]===

    $white = "255,255,255";
    $black = "0,0,0";
    $blue = "0x2c,0c6d,0xaf";
    // =======================================
    //     === ==========[ 构建颜色数组 ]===
    // 现在我们将所需的颜色放入
    //     数组(例如“$textcolor=white”,
    // 数组 $textcolor_array 代表
    //     "白色")
    $textcolor_array =explode(",", $$textcolor);
    // =======================[计算po
    //     按钮上文字的位置]===
做 {
    $textwidth = strlen($text) * imagefontwidth($font);
    $x = ($buttonwidth - $textwidth) / 2; $x = ceil($x);
    $y = $vmidth - (imagefontheight($font) / 2);
    $font--;
    } while (($x 0)); $字体;
    // =======================================
    //     === ===[ 现在我们创建按钮 ]===
    if (isset($width) || isset($heigth)) {// 预计大小会发生变化?
    $ima = imagecreatefromgif("$button.gif");// 打开输入 gif
    $im = imagecreate($buttonwidth,$buttonheigth); // 创建所需大小的 img
    $uglybg = ImageColorAllocate($im,0xf4,0xb2,0xe5);
    ImageRectangle($im,0,0,$buttonwidth,$buttonheigth,$uglybg);
    $dummy = imagecopyresized($im,$ima,0,0,0,0,$buttonwidth,$buttonheigth,$im_info[0],$im_info[1]);
    if ($dummy == "") {
    ImageDestroy($im); // 如果不起作用,请在下面创建默认值
    } else {;}
    ImageDestroy($ima);
    ImageColorTransparent($im,$uglybg);
    } else {
    $im = imagecreatefromgif("$button.gif");// 打开输入 gif
    }
    if ($im == "") { $im = imagecreate($按钮宽度,$按钮高度); // 如果未找到输入 gif,
    $rblue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);// 创建默认框
    ImageRectangle($im,0,0,200,100,$rblue);
    }
    $color = ImageColorAllocate($im, $textcolor_array[0], $textcolor_array[1], $textcolor_array[2]); // 分配颜色
    imagestring($im, $font, $x, $y, "$text", $color); // 将文本放在上面
    ImageGif($im);// 将按钮发送到浏览器
    ImageDestroy($im);// 释放已用内存
    ?>         

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具