PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » PHP资源共享 » sin()线的代码
本页主题: sin()线的代码 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

自由的龙

该用户目前不在线
级别: 中级程序员
精华: 1
发帖: 1264
威望: 1267 点
金钱: 12660 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2006-04-16
最后登录:2006-06-27

sin()线的代码


<?php
  $width = 400;
  $height = 300;  

  $data = array();
  for( $i = 0; $i < 500; $i++ )
  {
      $data []= sin( deg2rad( ( $i / 500 ) * 360 ) );
  }
 

  $xstart = $width/10;
  $ystart = $height - ($height/10);
 
  $image = imagecreate($width, $height);
  $back = imagecolorallocate($image, 255, 255, 255);
  $border = imagecolorallocate($image, 64, 64, 64);
 
  imageline( $image, $xstart, 0, $xstart, $ystart, $border );
  imageline( $image, $xstart, $ystart, $width, $ystart, $border );
 
  imagestring( $image, 2, $xstart-20, $ystart-10, "1", $border );
  imagestring( $image, 2, $xstart-20, 0, "-1", $border );
  imagestring( $image, 2, $xstart, $ystart+5, "0", $border );
  imagestring( $image, 2, $width-20, $ystart+5, "360", $border );
 
  $datatop = 1;
  $databottom = -1;
 
  $oldx = 0;
  $oldy = 0;
  $datacount = count( $data );
  $xscale = ( $width - $xstart ) / $datacount;
  $yscale = $ystart / ( $datatop - $databottom );
  $midline = $ystart / 2;
  for( $i = 0; $i < $datacount; $i++ )
  {
      $x = $xstart + ( $i * $xscale );
      $y = $midline - ( $data[$i] * $yscale );
      if ( $i > 0 )
      {
          imageline( $image, $oldx, $oldy, $x, $y, $border );
      }
      $oldx = $x;
      $oldy = $y;
  }header("Content-type: image/png");
  imagepng($image);
  imagedestroy($image);  
?>


[ 此贴被自由的龙在2006-05-11 14:01重新编辑 ]
顶端 Posted: 2006-04-20 09:11 | [楼 主]
alcow3306



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 1
威望: 2 点
金钱: 10 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2006-05-09
最后登录:2006-05-10


我怎么看不到源代码呢
顶端 Posted: 2006-05-09 15:11 | 1 楼
ok888ok



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 10
威望: 11 点
金钱: 100 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2006-08-31
最后登录:2006-08-31


路过顶一下。。。
顶端 Posted: 2006-08-31 23:14 | 2 楼
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » PHP资源共享

现在时间:10-12 07:52 Copyright © 2006 phpwhy.com 版权所有
浙ICP备05060669号

点击这里给我发消息关于我们 - 合作联系