search
Homephp教程php手册php绘制圆形的方法

这篇文章主要介绍了php绘制圆形的方法,详细分析了php绘制图形的基本步骤与绘制圆形的实现方法,需要的朋友可以参考下

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

php绘图的基本步骤,有四步(php.ini里的 extension = php_gb2.dll 组件首先需要启用)

1、创建画布;

2、画出所需要的图像(圆、直线、矩形、扇形、弧线.......);

3、输出到网页,或者另存;

4、销毁图片(目的是释放图像所占用的内存)。

网站开发最常用的三种图像格式:gif、jpg/jpeg、png

(1)gif格式:压缩率最高,但只能显示256色,可能造成色彩的丢失。优势:可能显示动画图像。

(2)jpg/jpeg格式:压缩率也比较高(有损压缩,,也会丢失一些色彩),网页上使用比较多。

(3)png格式:综合了gif和jpg的优势,它不能显示动画图像。高保真,支持无损压缩,色彩保存得最好,相对来说,要比 jpg/jpeg 要大一点。

php绘制圆形,代码如下:

复制代码 代码如下:

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

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft