PHP | imagickdraw popDefs()函数
ImagickDraw::popDefs()函数是PHP中的一个内置函数,用于终止定义列表。这些通常用于定义绘制命令,为了提高效率,应该更早地安全处理这些命令。此命令对绘图命令的外观没有影响。
句法:
bool ImagickDraw::popDefs( void )
参数:此函数不接受任何参数。
返回值:此函数在成功时返回 TRUE。
下面的程序说明了PHP中的ImagickDraw::popDefs()函数:
方案一:
newImage(800, 250, 'white');
// Create a new imagickDraw object
$draw = new ImagickDraw();
// Set some properties of objects
$draw->setStrokeColor('red');
$draw->setFillColor('purple');
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
// Create a definition
$draw->pushDefs();
$draw->setStrokeColor('green');
$draw->rectangle(150, 50, 300, 200);
$draw->popDefs();
// Draw a rectangle
$draw->rectangle(400, 50, 550, 200);
// 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 some properties of objects
$draw->setStrokeColor('red');
$draw->setFillColor('purple');
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
// Create a definition
$draw->pushDefs();
$draw->setStrokeColor('green');
$draw->circle(150, 50, 200, 200);
$draw->popDefs();
// Draw a circle
$draw->circle(400, 50, 450, 200);
// 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.popdefs。 PHP