📜  PHP | GmagickDraw arc()函数

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

PHP | GmagickDraw arc()函数

GmagickDraw::arc()函数是PHP中的一个内置函数,用于绘制落在图像上指定边界矩形内的弧线。

句法:

GmagickDraw GmagickDraw::arc( float $sx, float $sy,
              float $ex, float $ey, float $sd, float $ed )

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

  • $sx:指定矩形的起始x坐标。
  • $sy:它指定矩形的起始 y 坐标。
  • $ex:它指定矩形的结束 x 坐标。
  • $ey:它指定矩形的结束 y 坐标。
  • $sd:它指定旋转的起始度数。
  • $ed:它指定旋转的结束度数。

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

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

下面给出的程序说明了PHP中的GmagickDraw::arc()函数

使用图像:

程序1(从零开始画圆弧):

PHP
setFillColor('white');
   
// Function to draw rectangle
$draw->rectangle(0, 0, 800, 400);
   
// Set the fill color
$draw->setFillColor('white');
  
// Set the stroke color
$draw->setstrokecolor('black');
  
// Set the stroke width
$draw->setStrokeWidth(5); 
   
// Mark a arc
$draw->arc(60, -60, 460, 170, 0, 200);
   
// Use of drawimage function
$gmagick->drawImage($draw);
   
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>


php
setFillColor('red');
   
// Set the stroke color
$draw->setstrokecolor('green');
   
// Set the stroke width
$draw->setStrokeWidth(5); 
    
// Mark a arc
$draw->arc(160, -60, 360, 170, 50, 200);
    
// Use of drawimage function
$gmagick->drawImage($draw);
    
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>


输出:

程序 2(在图像上绘制弧线):

PHP

setFillColor('red');
   
// Set the stroke color
$draw->setstrokecolor('green');
   
// Set the stroke width
$draw->setStrokeWidth(5); 
    
// Mark a arc
$draw->arc(160, -60, 360, 170, 50, 200);
    
// 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.arc。 PHP