ImagickDraw::getStrokeDashOffset()函数是PHP中的内置函数,用于将偏移量添加到破折号模式中以开始破折号。该偏移量不过是开始由setStrokeDashArray()设置破折号之前要给的间距。
用法:
float ImagickDraw::getStrokeDashOffset( void )
参数:此函数不接受任何参数。
返回值:该函数返回一个包含偏移量的浮点值。
异常:该函数在错误时引发ImagickException。
以下示例程序旨在说明PHP中的ImagickDraw::getStrokeDashOffset()函数:
示例1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the stroke dash offset
$offset = $draw->getStrokeDashOffset();
echo $offset;
?>
输出:
0 // Which is the default value
示例2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the stroke dash offset
$draw->setStrokeDashOffset(50);
// Get the stroke dash offset
$offset = $draw->getStrokeDashOffset();
echo $offset;
?>
输出:
50
示例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 font size
$draw->setFontSize(15);
// 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(50, 200, 'The strokeDashOffset here is '
. $draw->getStrokeDashOffset());
// Set the stroke dash offset
$draw->setStrokeDashOffset(20);
// Draw a rectangle
$draw->rectangle(500, 50, 625, 175);
// Get the stroke dash array
$strokeDashArray = $draw->getStrokeDashArray();
// Annotate a text
$draw->annotation(450, 200, 'The strokeDashOffset here is '
. $draw->getStrokeDashOffset());
// 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.getstrokedashoffset.php
相关用法
- PHP ImagickDraw pop()用法及代码示例
- PHP ImagickDraw arc()用法及代码示例
- PHP ImagickDraw destroy()用法及代码示例
- PHP ImagickDraw setFontWeight()用法及代码示例
- PHP ImagickDraw setTextEncoding()用法及代码示例
- PHP ImagickDraw getTextAlignment()用法及代码示例
- PHP ImagickDraw getFillRule()用法及代码示例
- PHP ImagickDraw getTextEncoding()用法及代码示例
- PHP ImagickDraw setClipPath()用法及代码示例
- PHP ImagickDraw color()用法及代码示例
- PHP ImagickDraw getClipPath()用法及代码示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代码示例
- PHP ImagickDraw comment()用法及代码示例
- PHP ImagickDraw polyline()用法及代码示例
- PHP ImagickDraw pathMoveToRelative()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | ImagickDraw getStrokeDashOffset() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。