ImagickDraw::getTextDecoration()函数是PHP中的内置函数,用于在用文本注释时获取应用的修饰。
用法:
int ImagickDraw::getTextDecoration( void )
参数:此函数不接受任何参数。
返回值:此函数返回与DECORATION常量之一相对应的整数值。
DECORATION常量列表如下:
- imagick::DECORATION_NO(0)
- imagick::DECORATION_UNDERLINE(1)
- imagick::DECORATION_OVERLINE(2)
- imagick::DECORATION_LINETROUGH(3)
异常:该函数在错误时引发ImagickException。
下面给出的程序说明了PHP中的ImagickDraw::getTextDecoration()函数:
程序1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the text decoration
$textDecoration = $draw->getTextDecoration();
echo $textDecoration;
?>
输出:
1 // which is the default value.
程序2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the text decoration
$draw->setTextDecoration(2);
// Get the text decoration
$textDecoration = $draw->getTextDecoration();
echo $textDecoration;
?>
输出:
2
程序3:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'grey');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the fill color
$draw->setFillColor('purple');
// Set the font size
$draw->setFontSize(40);
// Get the text decoration
$textDecoration = $draw->getTextDecoration();
// Annotate a text
$draw->annotation(50, 100, 'The text decoration here is '
. $textDecoration);
// Set the text decoration
$draw->setTextDecoration(2);
// Get the text decoration
$textDecoration = $draw->getTextDecoration();
// Annotate a text
$draw->annotation(50, 200, 'The text decoration here is '
. $textDecoration);
// 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.gettextdecoration.php
相关用法
- PHP GmagickDraw gettextdecoration()用法及代码示例
- PHP ImagickDraw arc()用法及代码示例
- PHP ImagickDraw pop()用法及代码示例
- PHP ImagickDraw setTextAntialias()用法及代码示例
- PHP ImagickDraw setTextInterlineSpacing()用法及代码示例
- PHP ImagickDraw clone()用法及代码示例
- PHP ImagickDraw resetVectorGraphics()用法及代码示例
- PHP ImagickDraw setFillAlpha()用法及代码示例
- PHP ImagickDraw setFillOpacity()用法及代码示例
- PHP ImagickDraw getTextInterwordSpacing()用法及代码示例
- PHP ImagickDraw getFont()用法及代码示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothRelative()用法及代码示例
- PHP ImagickDraw setTextEncoding()用法及代码示例
- PHP ImagickDraw pathStart()用法及代码示例
- PHP ImagickDraw comment()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | ImagickDraw getTextDecoration() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。