PHP | imagickdraw poppattern()函数
ImagickDraw::popPattern()函数是PHP中的一个内置函数,用于终止包含要应用的设计的模式定义。
句法:
bool ImagickDraw::popPattern( void )
参数:此函数不接受任何参数。
返回值:此函数在成功时返回 TRUE。
异常:此函数在出错时抛出 ImagickException。
下面给出的程序说明了PHP中的ImagickDraw::popPattern()函数:
方案一:
newImage(800, 250, 'white');
// Create a new imagickDraw object
$draw = new ImagickDraw();
// Push the pattern
$draw->pushPattern("MyPattern", 0, 0, 50, 50);
for ($x = 0; $x < 50; $x += 10) {
for ($y = 0; $y < 50; $y += 5) {
$X = $x + (($y / 10) % 10);
$draw->rectangle($X, $y, $X + 5, $y + 5);
}
}
// Pop the pattern
$draw->popPattern();
// Set the fill Opacity
$draw->setFillOpacity(0);
// Set the fill pattern URL
$draw->setFillPatternURL('#MyPattern');
// Draw a rectangle
$draw->rectangle(0, 0, 900, 900);
// 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();
// Push the pattern
$draw->pushPattern("MyPattern", 0, 0, 50, 50);
for ($x = 0; $x < 50; $x += 10) {
for ($y = 0; $y < 50; $y += 5) {
$X = $x + (($y / 10) % 10);
$draw->circle($X, $y, $X, $y +1);
}
}
// Pop the pattern
$draw->popPattern();
// Set the fill Opacity
$draw->setFillOpacity(0);
// Set the fill pattern URL
$draw->setFillPatternURL('#MyPattern');
// Draw a rectangle
$draw->rectangle(0, 0, 900, 900);
// 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.poppattern。 PHP