php imageellipse()函数绘制以指定坐标为中心的椭圆。
语法
PHP imageellipse()函数具有以下语法。
bool imageellipse(resource $image , int $cx , int $cy , int $width , int $height , int $color )
参数
PHP imageellipse()函数具有以下参数。
- image - 由图像创建函数(如imagecreatetruecolor())返回的图像资源。
- cx - 中心的x坐标。
- 中心的cy-y坐标。
- width - 椭圆宽度。
- height - 椭圆高度。
- color - 椭圆的颜色。使用imagecolorallocate()创建的颜色标识符。
返回值
成功时返回TRUE,失败时返回FALSE。
画圆和椭圆
要在PHP中绘制圆和椭圆,请使用imageellipse()函数。
我们提供中心点,然后指定椭圆应该有多高和多宽。
imageellipse($myImage,90,60,160,50,$myBlack);
这个椭圆在像素上的中心是(90,60)。椭圆的宽度为160像素,高度为50像素。
要绘制圆形,只需描述具有相同宽度和高度的椭圆形:
imageellipse($myImage,90,60,70,70,$myBlack);
实例
<?php
/*
http://www.manongjc.com/article/1753.html
作者:码农教程
*/
$image = imagecreatetruecolor(400, 300);
// Select the background color.
$bg = imagecolorallocate($image, 0, 0, 0);
// Fill the background with the color selected above.
imagefill($image, 0, 0, $bg);
// Choose a color for the ellipse.
$col_ellipse = imagecolorallocate($image, 255, 255, 255);
// Draw the ellipse.
imageellipse($image, 200, 150, 300, 200, $col_ellipse);
// Output the image.
header(\"Content-type: image/png\");
imagepng($image);
?> 继续阅读与本文标签相同的文章
-
特斯拉上海超级工厂220千伏电力配套项目送电仪式今举行
2026-05-15栏目: 教程
-
安百科技携灵蜥RASP技术亮相中关村国际前沿科技成果展
2026-05-15栏目: 教程
-
“智慧+” 开启产业园区发展新时代
2026-05-15栏目: 教程
-
阿联酋宣布成立全球首所人工智能大学
2026-05-15栏目: 教程
-
再发射3万颗人造卫星!SpaceX公司有新想法,让人担忧的事来了
2026-05-15栏目: 教程
