首页 > 新闻动态 >  

新闻动态
NEWS

PHP哄骗GD库画曲线

添加时间:2013-7-23 点击量:

结果:

PHP代码

<?php 

Header(Content-type: image/png;Charset:utf-8); //声明

¥im = imagecreate(400,200);

//get color.
¥bg = imagecolorallocate(¥im,0,0,0);
¥red = imagecolorallocate(¥im,255,0,255);
¥white = imagecolorallocate(¥im,255,255,255);

¥arrowX = array(394,97,399,100,394,103);
¥arrowY = array(197,5,200,0,203,5);

//画曲线
for(¥i=0;¥i<380;¥i+=0.1){
¥x = ¥i/20;
¥y = sin(¥x);
¥y = 100 + 40¥y;
imagesetpixel(¥im,¥i+10,¥y,¥red);
}

//画X轴和Y轴
imageline(¥im,0,100,394,100,¥white);
imageline(¥im,200,5,200,200,¥white);

//画坐标title
imagestring(¥im,4,350,110,XShaft,¥white);

//画箭头
imagefilledpolygon(¥im,¥arrowX,3,¥white);
imagefilledpolygon(¥im,¥arrowY,3,¥white);

imagepng(¥im);
imagedestroy(¥im);

?>
容易发怒的意思就是: 别人做了蠢事, 然后我们代替他们, 表现出笨蛋的样子。—— 蔡康永
分享到: