ImagickDraw::getTextUnderColor()函數是PHP中的內置函數,用於獲取要放置在文本注釋下的背景矩形的顏色。默認情況下,此背景矩形是透明的。
用法:
ImagickPixel ImagickDraw::getTextUnderColor( void )
參數:此函數不接受任何參數。
返回值:此函數返回包含底色的ImagickPixel值。
以下示例程序旨在說明PHP中的ImagickDraw::getTextUnderColor()函數:
示例1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the text under color
$color = $draw->getTextUnderColor()->getColorAsString();
echo $color;
?>
輸出:
srgba(0, 0, 0, 0) // Which is the default transparent color.
示例2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the text under color
$draw->setTextUnderColor('green');
// Get the text under color
$color = $draw->getTextUnderColor()->getColorAsString();
echo $color;
?>
輸出:
srgb(0, 128, 0)
示例3:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, '#1cced4');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the font size
$draw->setFontSize(35);
// Set the text under color
$draw->setTextUnderColor('green');
// Annotate a text
$draw->annotation(50, 80, "The text under color here is "
. $draw->getTextUnderColor()->getColorAsString());
// Set the text under color
$draw->setTextUnderColor('blue');
// Annotate a text
$draw->annotation(50, 160, "The text under color here is "
. $draw->getTextUnderColor()->getColorAsString());
// 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.gettextundercolor.php
相關用法
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw color()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getTextUnderColor() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。