Home > Backend Development > PHP Tutorial > 007-PHP GD drawing process

007-PHP GD drawing process

不言
Release: 2023-03-23 10:18:01
Original
1843 people have browsed it

The content of this article is the GD drawing process of PHP. Now I share it with everyone. Friends in need can take a look


<?php
/**
 * GD库画图流程
 *      1. 新建空白画布(指定宽高)
 *      2. 创建颜料
 *      3. 画图形(椭圆,矩形,直线等),或写字
 *      4. 输出/保存图形
 *      5. 销毁画布(关闭画板)
 * 填充颜色注意事项:
 *      1.在画图之前填充的是整个背景色
 *      2.在画图之后填充,需要找准对应的坐标以填充
 *
 */

//1. 新建空白画布(指定宽高)
$pic = imagecreatetruecolor(200, 300);

//2. 创建颜料(RGB)
$red = imagecolorallocate($pic, 255, 0, 0);
$blur = imagecolorallocate($pic, 0,0,255);

//3. 画图形(椭圆,矩形,直线等),或写字
imageellipse($pic, 100, 150, 200, 300, $red);

//填充背景色(X Y 坐标)
imagefill($pic, 200, 10, $blue);

//4. 输出/保存图形
imagepng($pic , &#39;./t1.png&#39;);

//5. 销毁画布(关闭画板)
imagedestroy($pic);

?>
Copy after login

Related recommendations:

005-PHP obtains the visitor’s real IP

006-PHP common function encapsulation


The above is the detailed content of 007-PHP GD drawing process. For more information, please follow other related articles on the PHP Chinese website!

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