How to draw a circle in php_php gd library draws a circle

WBOY
Release: 2016-07-25 08:52:07
Original
2236 people have browsed it
  1. //1. Create canvas

  2. $im = imagecreatetruecolor(300,200);//Create a new true color image, the default background is black, and return the image identifier. There is also a function imagecreate that has been deprecated.

  3. //2. Draw the required image

  4. $red = imagecolorallocate($im,255,0,0);//Create a color for use
  5. imageellipse($im, 30,30,40,40,$red);//Draw a circle. Parameter description: 30, 30 are the center coordinates of the circle; 40, 40 are the width and height, if they are different, it is an ellipse; $red is the color of the circle (frame color)

  6. // 3. Output the image

  7. header("content-type: image/png");
  8. imagepng($im);//Output to the page. If there is a second parameter [,$filename], it means saving the image

  9. //4. Destroy the image and release the memory

  10. imagedestroy($im);
  11. ?>
Copy code


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!