for($i = 1;$i < 200;$i++){
   $x = mt_rand(1,$w-9);    
   $y = mt_rand(1,$h-9);
   $color = imagecolorallocate($im,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
   imagechar($im,1,$x,$y,"*",$color);
}
for($i = 1;$i < 200;$i++){
   $x = mt_rand(1,$w-9);    
   $y = mt_rand(1,$h-9);
这三句话是什么意思?================================================================================imagefilledrectangle($im,0,0,$w,$h,$white); 
imagerectangle($im,0,0,$w-1,$h-1,$black);    //为什么这个矩形的(X2,Y2)坐标是($w-1,$h-1 ) ??而又是从(0,0)开始的?================================================================================ $y1=rand(0,26);
 $y2=rand(0,26);
 $y3=rand(0,26);
 $y4=rand(0,26);
 imageline($im,0,$y1,$w,$y3,img_color_styled);
 imageline($im,0,$y2,$w,$y4,img_color_styled);
img_color_styled   是什么意思?

解决方案 »

  1.   

    1. mt_rand(1,9); //产生1~9之间的随机数2. 只是坐标的选择而已 没有特别含义 imagefilledrectangle($im,0,0,$w,$h,$white); 其中0 0表示左上角 $w,$h表示右下角3. img_color_styled相当于一个常量 系统自带的一种颜色 你可以试试看
      

  2.   

    1,为什么要用个FOR循环?
    2,如果是$w,$h的话 ,右边框和下边款看不见
      

  3.   

    1. 循环打出199个随即颜色的*2. 你可以把变量设置固定值试试$canvas = imagecreatetruecolor(200, 200);
    $pink = imagecolorallocate($canvas, 255, 105, 180);
    imagerectangle($canvas, 50, 50, 150, 150, $pink);
    header('Content-Type: image/jpeg');
    imagejpeg($canvas);
    imagedestroy($canvas);