📜  PHP | GmagickDraw ellipse()函数

📅  最后修改于: 2022-05-13 01:56:23.302000             🧑  作者: Mango

PHP | GmagickDraw ellipse()函数

GmagickDraw::ellipse()函数是PHP中的一个内置函数,用于在图像上绘制椭圆。

句法:

GmagickDraw GmagickDraw::ellipse( float $ox, 
float $oy, float $rx, float $ry, 
float $start, float $end )

参数:此函数接受上面提到的六个参数,如下所述:

  • $ox:指定椭圆的 x 坐标。
  • $oy:它指定椭圆的 y 坐标。
  • $rx:它指定椭圆的 x 半径。
  • $ry:它指定椭圆的 y 半径。
  • $start:指定椭圆的起点。
  • $end:指定椭圆的终点。

返回值:此函数在成功时返回一个 GmagickDraw 对象。

异常:此函数在出错时抛出 GmagickDrawException。

下面给出的程序说明了PHP中的GmagickDraw::ellipse()函数
程序 1(简单椭圆):

setFillColor('#0E0E0E');
  
// Function to draw rectangle
$draw->rectangle(-10, -10, 800, 400);
  
// Set the fill color
$draw->setFillColor('#3D99D4');
  
// Set the stroke width
$draw->setStrokeWidth(5);
  
// Draw a ellipse 
$draw->ellipse(125, 70, 100, 50, 0, 360); 
  
// Use of drawimage function
$gmagick->drawImage($draw);
  
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>

输出:

程序 2(描边椭圆):

setFillColor('#0E0E0E');
  
// Function to draw rectangle
$draw->rectangle(-10, -10, 800, 400);
  
// Set the fill color
$draw->setFillColor('blue');
  
// Set the stroke color
$draw->setstrokecolor('green');
  
// Set the stroke width
$draw->setStrokeWidth(5);
  
// Draw a ellipse 
$draw->ellipse(225, 70, 150, 50, 0, 360); 
  
// Use of drawimage function
$gmagick->drawImage($draw);
  
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>

输出:

参考: https://www. PHP.net/manual/en/gmagickdraw.ellipse。 PHP