ImagickDraw::getStrokeLineCap()函數是PHP中的一個內置函數,用於獲取在打開的子路徑被描邊時要使用的形狀。
用法:
int ImagickDraw::getStrokeLineCap( void )
參數:此函數不接受任何參數。
返回值:此函數返回與LINECAP常量之一相對應的整數值。
LINECAP常量列表如下:
- imagick::LINECAP_UNDEFINED(0)
- imagick::LINECAP_BUTT(1)
- imagick::LINECAP_ROUND(2)
- imagick::LINECAP_SQUARE(3)
異常:該函數在錯誤時引發ImagickException。
以下示例程序旨在說明PHP中的ImagickDraw::getStrokeLineCap()函數:
程序1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the stroke line cap
$lineCap = $draw->getStrokeLineCap();
echo $lineCap;
?>
輸出:
1 // Which corresponds to imagick::LINECAP_BUTT
程序2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the stroke line cap
$draw->setStrokeLineCap(3);
// Get the stroke line cap
$lineCap = $draw->getStrokeLineCap();
echo $lineCap;
?>
輸出:
3 // Which corresponds to imagick::LINECAP_SQUARE
程序3:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'black');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the fill color
$draw->setFillColor('black');
// Set the color of stroke
$draw->setStrokeColor('white');
// Set the stroke width
$draw->setStrokeWidth(3);
// Set the font size
$draw->setFontSize(25);
// Set the stroke dash array
$draw->setStrokeDashArray([20, 5, 19, 15, 5, 15]);
// Draw a rectangle
$draw->rectangle(100, 50, 225, 175);
// Annotate a text
$draw->annotation(10, 220, 'The strokeLineCap here is '
. $draw->getStrokeLineCap());
// Set the stroke line cap
$draw->setStrokeLineCap(2);
// Draw a rectangle
$draw->rectangle(500, 50, 625, 175);
// Annotate a text
$draw->annotation(400, 220, 'The strokeLineCap here is '
. $draw->getStrokeLineCap());
// 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.getstrokelinecap.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw setTextInterlineSpacing()用法及代碼示例
- PHP ImagickDraw getFont()用法及代碼示例
- PHP ImagickDraw clone()用法及代碼示例
- PHP ImagickDraw popPattern()用法及代碼示例
- PHP ImagickDraw resetVectorGraphics()用法及代碼示例
- PHP ImagickDraw setFillAlpha()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw getTextInterwordSpacing()用法及代碼示例
- PHP ImagickDraw setFillOpacity()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierRelative()用法及代碼示例
- PHP ImagickDraw getFontWeight()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getStrokeLineCap() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。