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

How to draw a straight line in php, how to draw a straight line in php_PHP tutorial

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

How to draw a straight line in php, how to draw a straight line in php

The example in this article describes how to draw a straight line 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
imageline($im,30,30,240,140,$red);//Draw a straight line. Parameter description: 30, 30 represents the starting point coordinates; 240, 140 represents the end point coordinates
//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/947213.htmlTechArticleHow to draw a straight line in php, how to draw a straight line in php. This article describes the method of drawing a straight line 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