如何在php中绘制半透明矩形? [英] how to draw semi-transparent rectangle in php?
本文介绍了如何在php中绘制半透明矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我想做的一个例子:
Here is an example what I would like to do:
这是结果:
function red_rectangle($img_src,$x1,$y1,$x2,$y2,$tr = 50)
{
// Load image
$img = imagecreatefromjpeg($img_src);
// Transparent red
$red = imagecolorallocatealpha($img, 255, 0, 0, $tr);
// Draw a white rectangle
imagefilledrectangle($img, $x1, $y1, $x2, $y2, $red);
// Save the image (overwrite)
imagejpeg($img, $img_src);
imagedestroy($img);
}
推荐答案
您需要使用 http://php.net/manual/zh-CN/function.imagefilledrectangle.php ,传递使用
You need to use http://php.net/manual/en/function.imagefilledrectangle.php, passing a color created with http://www.php.net/manual/en/function.imagecolorallocatealpha.php.
如您所见, http://php.net/manual/zh_cn/function.imagefilledrectangle.php 实际上是您要执行的操作.
As you can see, the example for http://php.net/manual/en/function.imagefilledrectangle.php is pratically what to you want to do.
这篇关于如何在php中绘制半透明矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文