PHP随机生成imagecolor
<?php //assign random rgb values $c1 = mt_rand(50,200); //r(ed) $c2 = mt_rand(50,200); //g(reen) $c3 = mt_rand(50,200); //b(lue) //test if we have used up palette if(imagecolorstotal($pic)>=255) { //palette used up; pick closest assigned color $color = imagecolorclosest($pic, $c1, $c2, $c3); } else { //palette NOT used up; assign new color $color = imagecolorallocate($pic, $c1, $c2, $c3); } ?>