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


我是使用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);
?>


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3