Home  >  Article  >  Backend Development  >  How to draw a rectangle in php, how to draw a rectangle in php_PHP tutorial

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

WBOY
WBOYOriginal
2016-07-13 10:09:051350browse

php method to draw a rectangle, php method to draw a rectangle

The example in this article describes how to draw a rectangle in PHP. Share it with everyone for your reference. The specific implementation method 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
imagerectangle($im,30,30,240,140,$red);//Draw a rectangle. Parameter description: 30,30 represents the coordinates of the upper left corner of the rectangle; 240,140 represents the coordinates of the lower right corner of the rectangle; $red represents the color
//imagefilledrectangle($im,30,30,240,140,$red);//Filled rectangle
//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/947212.htmlTechArticleHow to draw a rectangle in php, how to draw a rectangle in php. This example describes how to draw a rectangle in php. Share it with everyone for your reference. The specific implementation method is as follows: Copy the code...
Statement:
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