php绘图技术入门简介

原创
2016-07-25 08:52:08 737浏览
  1. //绘图技术 基本步骤 前提:在php.ini文件中启用gd库

  2. //创建画布 默认背景是黑色的
  3. $img=imagecreatetruecolor(400,300);
  4. //绘制各种图形
  5. //创建一个颜色
  6. $background = imagecolorallocate($img, 255, 0, 0);
  7. //画圆
  8. //imageellipse($img,30,30,50,50,$background);
  9. //椭圆
  10. //imageellipse($img,30,30,50,30,$background);
  11. //画直线
  12. //imageline($img,0,0,400,300,$background);
  13. //画矩形
  14. //imagerectangle ($img, 50 , 20 , 100 , 40 , $background);
  15. //填充矩形
  16. //imagefilledrectangle ($img, 50 , 20 , 100 , 40 , $background);
  17. //画弧线
  18. //imagearc($img, 100, 100, 150, 150, 180, 270, $background);
  19. //画扇型 IMG_ARC_CHORD直线连接了起始和结束点 IMG_ARC_PIE
  20. //imagefilledarc($img, 100, 100, 150, 150, 180, 270, $background,IMG_ARC_PIE);

  21. //拷贝图片到画布

  22. /*$scrImg=imagecreatefromgif('http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif');
  23. $scrImgInfo=getimagesize('http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif');
  24. imagecopy ($img,$scrImg,10,10,0,0,$scrImgInfo[0],$scrImgInfo[1]);
  25. */
  26. //imagecopy ($img,$scrImg,10,10,0,0,270,129);

  27. //写字

  28. //imagestring ($img , 5 , 20 , 20 , "hello,world", $background );
  29. //写中文
  30. $str="PHP绘画技术";
  31. imagettftext ($img , 30 , 0 , 50 ,50, $background , "MSYHBD.TTF" , $str);
  32. //输出图像到网页(或者另存为)
  33. header("content-type: image/png");
  34. imagepng($img);
  35. //销毁该图片(释放内存)
  36. imagedestroy($img);
  37. ?>

复制代码


声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
上一条:php观察者模式入门例子 下一条:php绘制饼状图(imagefilledarc方法)

相关文章

查看更多