ImagickDraw::getStrokeColor()函數是PHP中的內置函數,用於獲取用於撫摸對象輪廓的顏色。
用法:
ImagickPixel ImagickDraw::getStrokeColor( void )
參數:此函數不接受任何參數。
返回值:此函數返回包含筆觸顏色的ImagickPixel。
以下示例程序旨在說明PHP中的ImagickDraw::getStrokeColor()函數:
示例1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the stroke color
$strokeColor = $draw->getStrokeColor()->getColorAsString();
echo $strokeColor;
?>
輸出:
srgba(255, 255, 255, 0)
示例2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the stroke color
$draw->setStrokeColor('grey');
// Get the stroke color
$strokeColor = $draw->getStrokeColor()->getColorAsString();
echo $strokeColor;
?>
輸出:
srgb(190, 190, 190)
示例3:
<?php
// 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 width of stroke
$draw->setStrokeWidth(1);
// Set the color of stroke
$draw->setStrokeColor('red');
// Set the font size
$draw->setFontSize(40);
// Get the stroke color
$strokecolor = $draw->getStrokeColor()->getColorAsString();
// Annotate a text
$draw->annotation(50, 100,
'The stroke color here is ' . $strokecolor);
// Set the color of stroke
$draw->setStrokeColor('green');
// Get the stroke color
$strokecolor = $draw->getStrokeColor()->getColorAsString();
// Annotate a text
$draw->annotation(50, 200,
'The stroke color here is ' . $strokecolor);
// 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.getstrokecolor.php
相關用法
- PHP GmagickDraw getstrokecolor()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw pathStart()用法及代碼示例
- PHP ImagickDraw pathFinish()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
- PHP ImagickDraw pathEllipticArcRelative()用法及代碼示例
- PHP ImagickDraw getTextDecoration()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw clear()用法及代碼示例
- PHP ImagickDraw pathLineToHorizontalAbsolute()用法及代碼示例
- PHP ImagickDraw pathLineToRelative()用法及代碼示例
- PHP ImagickDraw bezier()用法及代碼示例
- PHP ImagickDraw affine()用法及代碼示例
- PHP ImagickDraw circle()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getStrokeColor() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。