PHP 中的 imagefilledellipse() 函数

phpserver side programmingprogramming更新于 2025/7/6 16:37:17

imagefilledellipse() 函数用于绘制填充的椭圆。

语法

imagefilledellipse( $img, $cx, $cy, $width, $height, $color )

参数

  • img使用 imagecreatetruecolor() 创建空白图像

  • cx 中心的 x 坐标。

  • cy 中心的 y 坐标。

  • width 椭圆的宽度。

  • height椭圆高度。

  • color 填充颜色。

返回

imagefilledellipse() 函数成功时返回 TRUE,失败时返回 FALSE。

示例

以下是示例:

<?php
   $img = imagecreatetruecolor(450, 290);
   $bgColor = imagecolorallocate($img, 140, 180, 140);
   imagefill($img, 0, 0, $bgColor);
   $ellipse = imagecolorallocate($img, 120, 50, 70);
   imagefilledellipse($img, 225, 150, 400, 250, $ellipse);
   header("Content-type: image/png");
   imagepng($img);
?>

输出

输出结果如下:


相关文章