Home > php教程 > php手册 > body text

php绘制一条直线的方法,php绘制一条方法

WBOY
Release: 2016-06-13 09:16:33
Original
911 people have browsed it

php绘制一条直线的方法,php绘制一条方法

本文实例讲述了php绘制一条直线的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:

//1、创建画布
$im = imagecreatetruecolor(300,200);//新建一个真彩色图像,默认背景是黑色,返回图像标识符。另外还有一个函数 imagecreate 已经不推荐使用。
//2、绘制所需要的图像
$red = imagecolorallocate($im,255,0,0);//创建一个颜色,以供使用
imageline($im,30,30,240,140,$red);//画一条直线。参数说明:30,30表示起点坐标;240,140表示终点坐标
//3、输出图像
header("content-type: image/png");
imagepng($im);//输出到页面。如果有第二个参数[,$filename],则表示保存图像
//4、销毁图像,释放内存
imagedestroy($im);
?>

希望本文所述对大家的php程序设计有所帮助。

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 Recommendations
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!