以前用actionscript写动态绘制三角函数曲线,其实php输出三角函数曲线也很简单。
<?php<BR> define("MAX_WIDTH_PIXEL", 600);<BR> define("MAX_HEIGHT_PIXEL", 240);</P><P> //发送标头信息<BR> header("Content-type: image/gif");</P><P> //建立图像<BR> $img = imageCreate(MAX_WIDTH_PIXEL, MAX_HEIGHT_PIXEL);</P><P> //设定颜色<BR> $bgcolor = imageColorAllocate($img, 0xff, 0xe9, 0xe9);<BR> $red = imageColorAllocate($img, 255, 0, 0);<BR> $blue = imageColorAllocate($img, 0, 0, 255);<BR> $brown = imageColorAllocate($img, 100, 0, 0);<BR> $black = imageColorAllocate($img, 0, 0, 0);</P><P> $width = MAX_WIDTH_PIXEL/2; //宽度<BR> $height = MAX_HEIGHT_PIXEL/2; //高度</P><P> //建立坐标轴<BR> imageLine($img, $width, 0, $width, MAX_HEIGHT_PIXEL, $black);//y轴<BR> imageLine($img, 0, $height, MAX_WIDTH_PIXEL, $height, $black);//x轴</P><P> //通过循环来实现函数图形的描绘<BR> for($i=0; $i<=MAX_WIDTH_PIXEL; $i++)<BR> {<BR> $y1 = 100 * sin($i/100 * M_PI);<BR> imageSetPixel($img, $i, $height+$y1, $blue);</P><P> $y2 = 100 * sin($i/300 * M_PI);<BR> imageSetPixel($img, $i, $height+$y2, $red);</P><P> $y3 = 100 * sin($i/300 * M_PI);<BR> imageSetPixel($img, $i, $height-$y3, $brown);<BR> }</P><P> //显示<b style="color:transparent">(、本文来源gao@!dai!ma.com搞$$代^@码网*</b><i>搞gaodaima代码</i>图形<BR> imageGif($img);</P><P> //释放资源<BR> imageDestroy($img);<BR> /*==隐逸鸟==*/<BR>?><BR>