当前位置: 首页> 函数类别大全> imagefilledellipse

imagefilledellipse

绘制填充的椭圆
名称:imagefilledellipse
分类:图像处理GD
所属语言:php
一句话介绍:绘制填充的椭圆

imagefilledellipse 函数

适用 PHP 版本

PHP 4.3.0 及以上版本

函数说明

imagefilledellipse 函数用于在图像中绘制一个填充的椭圆。可以通过指定椭圆的圆心位置、宽度和高度,以及颜色来进行绘制。

函数语法

bool imagefilledellipse(resource $image, int $cx, int $cy, int $width, int $height, int $color);

参数

  • image (resource): 目标图像的资源,通常是通过 imagecreate() 或 imagecreatetruecolor() 函数创建的图像。
  • cx (int): 椭圆圆心的 X 坐标。
  • cy (int): 椭圆圆心的 Y 坐标。
  • width (int): 椭圆的宽度。
  • height (int): 椭圆的高度。
  • color (int): 用于填充椭圆的颜色,可以使用 imagecolorallocate() 函数分配颜色。

返回值

成功时返回 true,失败时返回 false。

示例

以下示例展示如何使用 imagefilledellipse 函数绘制一个填充的红色椭圆。

示例代码的说明

本示例创建了一个 200x200 的空白图像,然后在图像中绘制一个红色填充的椭圆,圆心位于 (100, 100),宽度为 150,高度为 100。最后,将图像输出到浏览器,并清理资源。

示例代码

<?php
// 创建一个 200x200 的图像
$image = imagecreatetruecolor(200, 200);
<p>// 分配颜色<br>
$red = imagecolorallocate($image, 255, 0, 0);<br>
$white = imagecolorallocate($image, 255, 255, 255);</p>
<p>// 填充背景为白色<br>
imagefill($image, 0, 0, $white);</p>
<p>// 绘制一个红色的填充椭圆<br>
imagefilledellipse($image, 100, 100, 150, 100, $red);</p>
<p>// 输出图像到浏览器<br>
header('Content-Type: image/png');<br>
imagepng($image);</p>
<p>// 释放图像资源<br>
imagedestroy($image);<br>
?><br>

同类函数
热门文章