Home > Backend Development > PHP Tutorial > How to draw a circle in php, how to draw a circle in php_PHP tutorial

How to draw a circle in php, how to draw a circle in php_PHP tutorial

WBOY
Release: 2016-07-13 10:09:10
Original
1084 people have browsed it

How to draw a circle in php, how to draw a circle in php

The example in this article describes how to draw a circle in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

Basic steps for php drawing, there are four steps (the extension = php_gb2.dll component in php.ini needs to be enabled first)

1. Create canvas;

2. Draw the required image (circle, straight line, rectangle, sector, arc...);

3. Output to the web page, or save as another file;

4. Destroy the image (the purpose is to release the memory occupied by the image).

The three most commonly used image formats for website development: gif, jpg/jpeg, png

(1) GIF format: has the highest compression rate, but can only display 256 colors, which may cause color loss. Advantage: Possibility to display animated images.

(2) jpg/jpeg format: The compression rate is also relatively high (lossy compression will also lose some colors), and it is often used on web pages.

(3) png format: It combines the advantages of gif and jpg, but it cannot display animated images. High fidelity, supports lossless compression, has the best color preservation, and is relatively larger than jpg/jpeg.

php draws a circle , the code is as follows:

Copy code The code is as follows:
//1. Create canvas
$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.
//2. Draw the required image
$red = imagecolorallocate($im,255,0,0);//Create a color for use
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)
//3. Output image
header("content-type: image/png");
imagepng($im);//Output to the page. If there is a second parameter [,$filename], it means saving the image
//4. Destroy the image and release memory
imagedestroy($im);
?>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/947214.htmlTechArticleHow to draw a circle in php, how to draw a circle in php This article describes the method of drawing a circle in php. Share it with everyone for your reference. The specific implementation method is as follows: Basic steps of php drawing...
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