📜  PHP | imagickdraw popClipPath()函数

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

PHP | imagickdraw popClipPath()函数

ImagickDraw::popClipPath()函数是PHP中的一个内置函数,用于终止剪辑路径定义。剪辑路径用于创建决定应显示图像的哪一部分的剪辑区域。显示区域内的部分,而隐藏区域外的部分。

句法:

bool ImagickDraw::popClipPath( void )

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

返回值:此函数在成功时返回 TRUE。

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

方案一:

newImage(800, 250, 'white');
  
// Create a new imagickDraw object
$draw = new ImagickDraw();
  
// Set the stroke color
$draw->setStrokeColor('blue');
  
// Set the fill color
$draw->setFillColor('cyan');
  
// Set the stroke width
$draw->setStrokeWidth(2);
  
// Push the clip path
$draw->pushClipPath('testClipPath');
  
// This is the area which is going to be visible
$draw->rectangle(0, 0, 250, 250);
  
// Pop the clip path
$draw->popClipPath();
  
// Set the clip path
$draw->setClipPath('testClipPath');
  
// Draw a rectangle
$draw->rectangle(50, 50, 350, 350);
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

输出:

方案二:

newImage(800, 250, 'white');
  
// Create a new imagickDraw object
$draw = new ImagickDraw();
  
// Set font size
$draw->setFontSize(60);
  
// Push the clip path
$draw->pushClipPath('testClipPath');
  
// This is the area which is going to be visible
$draw->rectangle(0, 0, 250, 250);
  
// Pop the clip path
$draw->popClipPath();
  
// Set the clip path
$draw->setClipPath('testClipPath');
  
// Annotate the text which is going to be clipped
$draw->annotation(0, 150, 'Hello World');
  
// 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.popclippath。 PHP