PHP | imagickdraw getTextDecoration()函数
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()函数:
方案一:
getTextDecoration();
echo $textDecoration;
?>
输出:
1 // which is the default value.
方案二:
setTextDecoration(2);
// Get the text decoration
$textDecoration = $draw->getTextDecoration();
echo $textDecoration;
?>
输出:
2
方案 3:
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