ImagickDraw::pop()函數是PHP中的一個內置函數,用於銷毀堆棧中的當前ImagickDraw,並返回先前推送的ImagickDraw。對於每個pop()函數,必須已經有一個等效的push()函數。
用法:
bool ImagickDraw::pop( void )
參數:此函數不接受任何參數。
返回值:成功時此函數返回TRUE。
以下示例程序旨在說明PHP中的ImagickDraw::pop()函數:
程序1:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create an image on imagick object
$imagick->newImage(800, 250, 'white');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the fill color
$draw->setFillColor('blue');
// Set the font size
$draw->setFontSize(70);
// Push
$draw->push();
// Annotate a text
$draw->annotation(250, 70, 'Hello');
// Pop
$draw->pop();
// Set the fill color for new object
$draw->setFillColor('green');
// Annotate a text
$draw->annotation(250, 170, 'World');
// 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 the stroke color
$draw->setStrokeColor('red');
// Set the fill color
$draw->setFillColor('blue');
// Set the stroke width
$draw->setStrokeWidth(5);
// Set the font size
$draw->setFontSize(72);
// Push
$draw->push();
// Translate the object
$draw->translate(50, 50);
// Draw a circle
$draw->circle(250, 70, 250, 130);
// Pop because we want to draw a new
// circle with new properties.
$draw->pop();
// Set the stroke color for new object
$draw->setStrokeColor('violet');
// Set the fill color for new object
$draw->setFillColor('green');
// Draw a new circle
$draw->circle(250, 70, 250, 130);
// 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.pop.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothAbsolute()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setFillOpacity()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setFontSize()用法及代碼示例
- PHP ImagickDraw pathStart()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw polygon()用法及代碼示例
- PHP ImagickDraw setTextAntialias()用法及代碼示例
- PHP ImagickDraw setTextDecoration()用法及代碼示例
- PHP ImagickDraw setTextUnderColor()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw pop() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。