Home php教程 php手册 php绘制一条弧线的方法

php绘制一条弧线的方法

Jun 06, 2016 pm 08:12 PM
php method draw

这篇文章主要介绍了php绘制一条弧线的方法,主要涉及GD库中imagearc方法的使用技巧,需要的朋友可以参考下

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

弧线相当于截取了椭圆的一部分。代码如下:

复制代码 代码如下:

//1、创建画布
$im = imagecreatetruecolor(300,200);//新建一个真彩色图像,默认背景是黑色,返回图像标识符。另外还有一个函数 imagecreate 已经不推荐使用。
//2、绘制所需要的图像
$red = imagecolorallocate($im,255,0,0);//创建一个颜色,以供使用
imagearc($im,100,80,120,90,0,120,$red);//画一条弧线(椭圆或圆形是一条特殊的弧线)。参数理解,相当于截取了椭圆/圆形的一部分。(100,80)表示中心点;(120,90)表示(椭圆)宽度与高;(0,120):0表示起点,中心点水平向右直线,与弧线交叉点,,为0点。120表示从起点开始,顺时针转120度(特殊:当为360时,相当于转了一圈,得到一个圆)。
//3、输出图像
header("content-type: image/png");
imagepng($im);//输出到页面。如果有第二个参数[,$filename],则表示保存图像
//4、销毁图像,释放内存
imagedestroy($im);
?>

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

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

See all articles