📜  PHP | imagickdraw getStrokeDashArray()函数

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

PHP | imagickdraw getStrokeDashArray()函数

ImagickDraw::getStrokeDashArray()函数是PHP中的一个内置函数,用于获取一个数组,该数组表示用于描边路径的破折号和间隙的模式。

句法:

array ImagickDraw::getStrokeDashArray( void )

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

返回值:此函数返回一个数组,其中包含成功时的笔划破折号,如果未设置则返回空数组。

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

方案一:

getStrokeDashArray();
print("
".print_r($array, true)."
"); ?>

输出:

Array // Empty array which is the default value
(
)

方案二:

setStrokeDashArray([20, 5, 20, 5, 5, 5, ]);
  
// Get the stroke dash array
$array = $draw->getStrokeDashArray();
print("
".print_r($array, true)."
"); ?>

输出:

Array
(
    [0] => 20
    [1] => 5
    [2] => 20
    [3] => 5
    [4] => 5
    [5] => 5
)

方案 3:

newImage(800, 250, 'black');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the fill color
$draw->setFillColor('black');
  
// Set the color of stroke
$draw->setStrokeColor('red');
  
// Set the font size
$draw->setFontSize(15);
  
// Draw a rectangle
$draw->rectangle(100, 50, 225, 175);
  
// Annotate a text
$draw->annotation(50, 200, 'The strokeDashArray here is default');
  
// Set the stroke dash array
$draw->setStrokeDashArray([20, 5, 19, 15, 5, 15, ]);
  
// Draw a rectangle
$draw->rectangle(500, 50, 625, 175);
  
// Get the stroke dash array
$strokeDashArray = $draw->getStrokeDashArray();
  
// Annotate a text
$draw->annotation(450, 200, 'The strokeDashArray here is ' 
                  . implode(" ", $strokeDashArray));
  
// 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.getstrokedasharray。 PHP