search
Homephp教程php手册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

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

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.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),