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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。