欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-05-14 11:55:01
由于php的本色表参数只能支持256,为了能实现显示8色或更多的色带,我使用了参数传递的方法来实现。具体实现的代码如下:1、生成色带图形的程序transition.php&...
由于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="./transition.php?x=0&y=0&z=0">
    </td>
</tr>
<tr>
    <td><!--色带2-->
    <input type="image" src="./transition.php?x=0&y=0&z=1">
    </td>
</tr>
<tr>
    <td><!--色带3-->
    <input type="image" src="./transition.php?x=0&y=1&z=0">
    </td>
</tr>
<tr>
    <td><!--色带4-->
    <input type="image" src="./transition.php?x=0&y=1&z=1">
    </td>
</tr>
<tr>
    <td><!--色带5-->
    <input type="image" src="./transition.php?x=1&y=0&z=0">
    </td>
</tr>
<tr>
    <td><!--色带6-->
    <input type="image" src="./transition.php?x=1&y=0&z=1">
    </td>
</tr>
<tr>
    <td><!--色带7-->
    <input type="image" src="./transition.php?x=1&y=1&z=0">
    </td>
</tr>
<tr>
    <td><!--色带8-->
    <input type="image" src="./transition.php?x=1&y=1&z=1">
    </td>
</tr>
</table>
</body>
</html>