加入收藏 | 设为首页 | 会员中心 | 我要投稿 焦作站长网 (https://www.0391zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP实现的功能是显示8条基色色带

发布时间:2020-03-21 17:50:16 所属栏目:PHP教程 来源:互联网
导读:PHP实现的功能是显示8条基色色带
由于PHP的本色表参数只能支持256,为了能实现显示8色或更多的色带,我使用了参数传递的方法来实现。具体实现的代码如下:

1、生成色带图形的程序
transition.php
<?php
/*
*  功能:生成色带图形
*  程序员:wlxz
* 日期:2002-00-00
*/

Header("Content-type: image/Png");
$im = ImageCreate(255,50);
$bgcolor = ImageColorAllocate($im, 0, 0, 0);

$x = trim($_GET['x']);
$y = trim($_GET['y']);
$z = trim($_GET['z']);

    for($i=0;$i<255;$i++){
        $fontcol = ImageColorAllocate($im, $i*$x, $i*$y, $i*$z);
        ImageLine($im, $i, 0, $i, 50, $fontcol);
    }

ImagePng($im);
ImageDestroy($im);
?>

2、调用生成多个不同的图形
view_color.php
<?php
/*
*  功能:
*  程序员:向黎
* 日期:2002-00-00
*/
?>
<html>
<head>
<title>  </title>
<meta name="Author" content="XIANG Li">
</head>

<body>
<table>
<tr>
    <td><!--色带1-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=0&y=0&z=0">
    </td>
</tr>
<tr>
    <td><!--色带2-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=0&y=0&z=1">
    </td>
</tr>
<tr>
    <td><!--色带3-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=0&y=1&z=0">
    </td>
</tr>
<tr>
    <td><!--色带4-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=0&y=1&z=1">
    </td>
</tr>
<tr>
    <td><!--色带5-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=1&y=0&z=0">
    </td>
</tr>
<tr>
    <td><!--色带6-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=1&y=0&z=1">
    </td>
</tr>
<tr>
    <td><!--色带7-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=1&y=1&z=0">
    </td>
</tr>
<tr>
    <td><!--色带8-->
    <input type="image" src=http://www.jb51.net/article/"./transition.php?x=1&y=1&z=1">
    </td>
</tr>
</table>
</body>
</html>

(编辑:焦作站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读