📜  PHP | imagickdraw getStrokeLineCap()函数

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

PHP | imagickdraw getStrokeLineCap()函数

ImagickDraw::getStrokeLineCap()函数是PHP中的一个内置函数,用于在打开子路径被描边时获取要在其末尾使用的形状。

句法:

int ImagickDraw::getStrokeLineCap( void )

参数:此函数不接受任何参数。

返回值:此函数返回对应于 LINECAP 常量之一的整数值。

LINECAP 常量列表如下:

  • imagick::LINECAP_UNDEFINED (0)
  • imagick::LINECAP_BUTT (1)
  • imagick::LINECAP_ROUND (2)
  • imagick::LINECAP_SQUARE (3)

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

下面的程序说明了PHP中的ImagickDraw::getStrokeLineCap()函数

方案一:

getStrokeLineCap();
echo $lineCap;
?>

输出:

1 // Which corresponds to imagick::LINECAP_BUTT

方案二:

setStrokeLineCap(3);
  
// Get the stroke line cap
$lineCap = $draw->getStrokeLineCap();
echo $lineCap;
?>

输出:

3 // Which corresponds to imagick::LINECAP_SQUARE

方案 3:

newImage(800, 250, 'black');
    
// Create a new ImagickDraw object
$draw = new ImagickDraw();
    
// Set the fill color
$draw->setFillColor('black');
    
// Set the color of stroke
$draw->setStrokeColor('white');
  
// Set the stroke width
$draw->setStrokeWidth(3);
    
// Set the font size
$draw->setFontSize(25);
   
 // Set the stroke dash array
$draw->setStrokeDashArray([20, 5, 19, 15, 5, 15]);
   
// Draw a rectangle
$draw->rectangle(100, 50, 225, 175);
    
// Annotate a text
$draw->annotation(10, 220, 'The strokeLineCap here is '
         . $draw->getStrokeLineCap());
   
// Set the stroke line cap
$draw->setStrokeLineCap(2);
    
// Draw a rectangle
$draw->rectangle(500, 50, 625, 175);
    
// Annotate a text
$draw->annotation(400, 220, 'The strokeLineCap here is '
         . $draw->getStrokeLineCap());
    
// Render the draw commands
$imagick->drawImage($draw);
    
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

输出:

参考: https://www. PHP.net/manual/en/imagickdraw.getstrokelinecap。 PHP