可以使用如下代码生成随机颜色:

$red = rand(0, 255);
$green = rand(0, 255);
$blue = rand(0, 255);
$color = imagecolorallocate($image, $red, $green, $blue);

其中,rand 函数用于生成 0 到 255 之间的随机数,$red$green$blue 分别表示红、绿、蓝三种颜色的值,$color 即为生成的随机颜色。

PHP imagecolorallocate: 生成随机颜色的方法

原文地址: https://www.cveoy.top/t/topic/kpoN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录