php使用GD实现颜色渐变实例

yipeiwu_com4年前PHP代码库

本文实例讲述了php使用GD实现颜色渐变的方法。分享给大家供大家参考。具体实现方法如下:

<?php
$im = imagecreate(255, 255);
$bg = imagecolorallocate($im, 0, 0, 0);
for ($i = 255; $i >= 0; $i--) {
    $color = imagecolorallocate($im, $i, $i, $i);
    imagefilledrectangle($im, 0, $i, 255, 1, $color);
}
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>

效果图如下:

希望本文所述对大家的php程序设计有所帮助。

相关文章

php+ajax实时输入自动搜索匹配的方法

本文实例讲述了php+ajax实输入自动搜索匹配的方法分享给大家供大家参考。具体分析如下: 第一种方法利用了jquery autocomplete,第二种使用了jquery ajax,其...

php5编程中的异常处理详细方法介绍

1 首先是try,catch  <?php  $path = "D:\\\\in.txt";  try //检...

php 无限分类的树类代码

复制代码 代码如下:<?php /** by lenush; */ class Tree { var $data = array(); var $child = array(-1=...

PHP在字符断点处截断文字的实现代码

复制代码 代码如下: //所谓断字 (word break),即一个单词可在转行时断开的地方。这一函数将在断字处截断字符串。 // Please acknowledge use of t...

php字符串按照单词进行反转的方法

本文实例讲述了php字符串按照单词进行反转的方法。分享给大家供大家参考。具体分析如下: 下面的php代码可以将字符串按照单词进行反转输出,实际上市现将字符串按照空格分隔到数组,然后对数组...