发信人: jackyz() 
整理人: dalasthunder(2002-07-25 05:56:04), 站内信件
 | 
 
 
sample php script (gif)
 ---------------------------------------------------------------------- ----------
 <? 
 // remember to use php3_gd.dll in php.ini 
 // refered as <img src="testgif.php"> 
 
 Header("Content-type: image/gif"); 
 define( "WIDTH", 400 ); 
 define( "HEIGHT", 300 ); 
 define( "BORDER", 20 ); 
  
 $im = ImageCreate(WIDTH, HEIGHT); 
 $cx = ImageSX( $im ); 
 $cy = ImageSY( $im );     
 $dx = $cx / 12; 
 $dy = $cy / 10; 
 
 // prepare colors
 
 $clr_background = ImageColorAllocate($im, 0xff, 0xff, 0xff); 
 $clr_rect = ImageColorAllocate( $im, 0xff, 0xff, 0xcc ); 
 $clr_fore = ImageColorAllocate( $im, 0, 0, 0 ); 
 $clr_line = ImageColorAllocate( $im, 0xff, 0, 0 ); 
 $clr_str = ImageColorAllocate($im, 0, 0, 0xff ); 
 
 // draw background     
 
 ImageFilledRectangle( $im, BORDER, BORDER, $cx-BORDER, $cy-BORDER,$clr _rect );
 ImageRectangle( $im, BORDER, BORDER, $cx-BORDER, $cy-BORDER, $clr_fore  );
      
 // draw dimension lines 
 
 for( $i=$dx+BORDER; $i<$cx-BORDER; $i+=$dx ){ 
   ImageDashedLine( $im, $i, 0+BORDER, $i, $cy-BORDER, $clr_fore ); 
 } 
 for( $j=$dy+BORDER; $j<$cy-BORDER; $j+=$dy ){ 
   ImageDashedLine( $im, 0+BORDER, $j, $cx-BORDER, $j, $clr_fore ); 
 } 
      
 // draw randomized curve 
 
 srand((double)microtime()*1000000); 
 $y = $cy / 2; 
 for( $i=BORDER; $i<$cx-BORDER; $i+=1 ){ 
   $old_y = $y; 
   $y += rand( -5, 5 ); // can also get data from database here 
   ImageLine( $im, $i, $old_y, $i+1, $y, $clr_line ); 
 } 
      
 // draw labels     
 
 $str = "time (month)"; 
 ImageString( $im, 4, ($cx-7.5*strlen($str))/2, $cy-20, $str, $clr_str) ; 
 $str = "value (dollar)"; 
 ImageStringUp( $im, 4, 0, ($cy+7.5*strlen($str))/2, $str, $clr_str );  
 
 ImageGif($im); 
 ImageDestroy($im); 
 
 ?> 
 -- 
 .鲜.香.麻.辣.烫. 
 ---------------------------------------------------------------------- ---
 转载自"CGI论坛"
 原文由"twinhotpot(火锅)"发表
  -- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.96.135.109]
  | 
 
 
 |