imageellipse()
imageellipse()函数接受六个参数,分别是:
函数执行成功时返回 true,如果失败则返回 false。
<?php
// 创建一个空白的图像
$image = imagecreatetruecolor(700, 350);
// 选择背景色
$bg = imagecolorallocate($image, 0, 0, 0);
// 填充背景色
imagefill($image, 0, 0, $bg);
// 为椭圆选择颜色
$col_ellipse = imagecolorallocate($image, 255, 255, 255);
// 绘制椭圆
imageellipse($image, 325, 175, 500, 175, $col_ellipse);
// 输出图像
header("Content-type: image/png");
imagepng($image);
?>
<?php
// 创建一个空白图像
$image = imagecreatetruecolor(700, 600);
// 设置背景颜色
$bg = imagecolorallocate($image, 122, 122, 122);
// 填充背景颜色
imagefill($image, 0, 0, $bg);
// 设置椭圆的颜色
$col_ellipse = imagecolorallocate($image, 0, 255, 255);
// 绘制椭圆
imageellipse($image, 250, 300, 300, 550, $col_ellipse);
// 输出图像
header("Content-type: image/gif");
imagepng($image);
?>
通过以上两个示例,我们演示了如何在PHP中使用 imageellipse() 函数绘制椭圆。此函数适用于各种图像绘制任务,无论是在图形处理应用中,还是在Web开发中处理图像时都能派上用场。