当前位置: 首页 > 图文教程 > 网络编程 > PHP > PHP教程:imagefilledrectangle函数生成渐变图片

PHP
抛开cookie使用session
实例讲解session的使用方法
zendoptimizer配置指南
开始了解 PHP V5 中的对象
apache 2.2.2 + PHP5.1.4 不能运行的解决办法.
Guard编码程序在指定虚拟主机上运行
PHP编程:探索字串的奥秘
用phpUnit帮你调试php程序
PHP开发中文件操作疑难FAQ
用PHP与XML 联手进行网站编程
php5手动最简安装方法
LAMP(Linux+Apache+MySQL+PHP)服务器的性能优化
PHP和COM
WINDOWS服务器安装多套PHP
让IIS支持PHP
PHP学习宝典-第一章
PHP学习宝典-第二章
PHP学习宝典-第二章 (续篇)
PHP学习宝典-第三章
PHP学习宝典-第三章 (续篇)

PHP教程:imagefilledrectangle函数生成渐变图片


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-04   浏览: 220 ::
收藏到网摘: n/a

如下图,只有生成一条就行了,其他都是一样的操作。还望高手能显显身手。

 

我是使用GD的 imagefilledrectangle 函数来实现的. 不知是否有更好的解法

<?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);
?>