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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。