好吧,几个月来我一直在研究 GD Image,我想用它完成的任务是创建一个脚本,该脚本采用现有图像,然后创建一个在它下面淡出到半透明的反射.
以下指南展示了如何使用不透明颜色:TalkPHP 论坛链接
在该论坛中,Rendair 描述了一种使用颜色覆盖动态绘制渐变的方法,并使用以下 PHP 代码:
// Next we draw a GD line into our gradient_line
imageline ($gradient_line, 0, 0, $imgName_w, 0, $gdGradientColor);
$i = 0;
$transparency = 30; //from 0 - 100
while ($i < $gradientHeight) //create line by line changing as we go
{
imagecopymerge ($background, $gradient_line, 0,$gradient_y_startpoint, 0, 0, $imgName_w, 1, $transparency);
++$i;
++$gradient_y_startpoint;
if ($transparency == 100) {
$transparency = 100;
}
else
{
// this will determing the height of the
//reflection. The higher the number, the smaller the reflection.
//1 being the lowest(highest reflection)
$transparency = $transparency + 1;
}
}
我试图实现的是一种效果,我们同样使用 alpha 功能将每一行淡化为一个更半透明的阴影,但似乎我很难一次应用一行。到目前为止,我只能制作图像的一小部分(一条大线),然后用半透明覆盖它,我似乎无法让每条线再褪色一点。所以我的预期结果应该是初始图像,然后是一个反射副本,褪色到 100% alpha 透明,但我似乎无法做到这一点。
那里有任何有天才想法的 PHP 人吗?
更新:这个问题为我赢得了风滚草徽章。