预览模式: 普通 | 列表

PHP利用GD库画曲线

效果:
 
 
PHP代码
 
PHP代码
  1. <?php   
  2. Header('Content-type: image/png;Charset:utf-8'); //声明图片  
  3.   
  4. $im = imagecreate(400,200);  
  5.   
  6. //get color.  
  7. $bg = imagecolorallocate($im,0,0,0);  
  8. $red = imagecolorallocate($im,255,0,255);  
  9. $white = imagecolorallocate($im,255,255,255);  
  10.   
  11. $arrowX = array(394,97,399,100,394,103);  
  12. $arrowY = array(197,5,200,0,203,5);                 
  13.   
  14. //画曲线  
  15. for($i=0;$i<380;$i+=0.1){  
  16.     $x = $i/20;  
  17.     $y = sin($x);  
  18.     $y = 100 + 40*$y;  
  19.     imagesetpixel($im,$i+10,$y,$red);  
  20. }  
  21.   
  22. //画X轴和Y轴  
  23. imageline($im,0,100,394,100,$white);  
  24. imageline($im,200,5,200,200,$white);  
  25.   
  26. //画坐标title  
  27. imagestring($im,4,350,110,'XShaft',$white);  
  28.   
  29. //画箭头  
  30. imagefilledpolygon($im,$arrowX,3,$white);  
  31. imagefilledpolygon($im,$arrowY,3,$white);  
  32.   
  33. imagepng($im);  
  34. imagedestroy($im);  
  35.   
  36. ?>  
 

Tags: php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 377

搬瓦工免费更换IP网址

搬瓦工每10周可以免费更换一次被封的IP

https://kiwivm.64clouds.com/main-exec.php?mode=blacklistcheck

最新消息:此功能已失效!

Tags: 搬瓦工

分类:业界文摘 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 401

 广告位

↑返回顶部↑