ImagickDraw::popClipPath()函数是PHP中的内置函数,用于终止clip-path定义。剪切路径用于创建剪切区域,该剪切区域决定应显示图像的哪一部分。显示区域内部的零件,而隐藏外部的零件。
用法:
bool ImagickDraw::popClipPath( void )
参数:此函数不接受任何参数。
返回值:成功时此函数返回TRUE。
以下示例程序旨在说明PHP中的ImagickDraw::popClipPath()函数:
程序1:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->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();
?>
输出:
程序2:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->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
相关用法
- PHP ImagickDraw arc()用法及代码示例
- PHP ImagickDraw pop()用法及代码示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothAbsolute()用法及代码示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代码示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代码示例
- PHP ImagickDraw setFontSize()用法及代码示例
- PHP ImagickDraw pathStart()用法及代码示例
- PHP ImagickDraw getStrokeLineJoin()用法及代码示例
- PHP ImagickDraw getStrokeLineCap()用法及代码示例
- PHP ImagickDraw setFontWeight()用法及代码示例
- PHP ImagickDraw setStrokeLineCap()用法及代码示例
- PHP ImagickDraw setTextAntialias()用法及代码示例
- PHP ImagickDraw setTextDecoration()用法及代码示例
- PHP ImagickDraw setTextUnderColor()用法及代码示例
- PHP ImagickDraw polygon()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | ImagickDraw popClipPath() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。