Introduction to PHP drawing technology

WBOY
Release: 2016-07-25 08:52:08
Original
1134 people have browsed it
  1. //Basic steps of drawing technology Prerequisite: Enable the gd library in the php.ini file

  2. //Create a canvas with a default background of black
  3. $img=imagecreatetruecolor(400,300) ;
  4. //Draw various graphics
  5. //Create a color
  6. $background = imagecolorallocate($img, 255, 0, 0);
  7. //Draw a circle
  8. //imageellipse($img,30,30,50,50 ,$background);
  9. //Ellipse
  10. //imageellipse($img,30,30,50,30,$background);
  11. //Draw a straight line
  12. //imageline($img,0,0,400,300,$background);
  13. //Draw a rectangle
  14. //imagerectangle ($img, 50, 20, 100, 40, $background);
  15. //Fill the rectangle
  16. //imagefilledrectangle ($img, 50, 20, 100, 40, $background);
  17. //Draw an arc
  18. //imagearc($img, 100, 100, 150, 150, 180, 270, $background);
  19. //Draw a fan-shaped IMG_ARC_CHORD straight line connecting the starting and ending points IMG_ARC_PIE
  20. //imagefilledarc ($img, 100, 100, 150, 150, 180, 270, $background,IMG_ARC_PIE);

  21. //Copy the image to the canvas

  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. < ;p>//Write words
  28. //imagestring ($img, 5, 20, 20, "hello,world", $background);
  29. //Write Chinese
  30. $str="PHP painting technology";
  31. imagettftext ($img , 30 , 0 , 50 ,50, $background , "MSYHBD.TTF" , $str);
  32. //Output the image to the web page (or save it as)
  33. header("content-type: image/png");
  34. imagepng ($img);
  35. //Destroy the image (release memory)
  36. imagedestroy($img);
  37. ?>

Copy code


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template