📜  PHP | imagickdraw getStrokeColor()函数

📅  最后修改于: 2022-05-13 01:56:45.488000             🧑  作者: Mango

PHP | imagickdraw getStrokeColor()函数

ImagickDraw::getStrokeColor()函数是PHP中的一个内置函数,用于获取用于描边对象轮廓的颜色。

句法:

ImagickPixel ImagickDraw::getStrokeColor( void )

参数:此函数不接受任何参数。

返回值:此函数返回包含笔画颜色的 ImagickPixel。

下面的程序说明了PHP中的ImagickDraw::getStrokeColor()函数

方案一:

getStrokeColor()->getColorAsString();
echo $strokeColor;
?>

输出:

srgba(255, 255, 255, 0)

方案二:

setStrokeColor('grey');
  
// Get the stroke color
$strokeColor = $draw->getStrokeColor()->getColorAsString();
echo $strokeColor;
?>

输出:

srgb(190, 190, 190)

方案 3:

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