SoFunction
Updated on 2025-04-09

The function implemented by PHP is to display 8 base color bands

Since PHP's natural color table parameters can only support 256, in order to display 8 colors or more ribbons, I used the parameter passing method to achieve it. The specific implementation code is as follows:

1. Program for generating ribbon graphics

<?php
/*
*  Function: Generate ribbon graphics
*  Programmer: wlxz
*Date: 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. Call to generate multiple different graphics
view_color.php
<?php
/*
* Function:
*  Programmer: Xiang Li
*Date: 2002-00-00
*/
?>
<html>
<head>
<title>  </title>
<meta name="Author" content="XIANG Li">
</head>

<body>
<table>
<tr>
<td><!--Rich 1-->
    <input type="image" src="./?x=0&y=0&z=0">
    </td>
</tr>
<tr>
<td><!--Rich 2-->
    <input type="image" src="./?x=0&y=0&z=1">
    </td>
</tr>
<tr>
<td><!--Rich 3-->
    <input type="image" src="./?x=0&y=1&z=0">
    </td>
</tr>
<tr>
<td><!--Rich 4-->
    <input type="image" src="./?x=0&y=1&z=1">
    </td>
</tr>
<tr>
<td><!--Rich 5-->
    <input type="image" src="./?x=1&y=0&z=0">
    </td>
</tr>
<tr>
<td><!--Rich 6-->
    <input type="image" src="./?x=1&y=0&z=1">
    </td>
</tr>
<tr>
<td><!--Rich 7-->
    <input type="image" src="./?x=1&y=1&z=0">
    </td>
</tr>
<tr>
<td><!--Rich 8-->
    <input type="image" src="./?x=1&y=1&z=1">
    </td>
</tr>
</table>
</body>
</html>