ImagickDraw::getStrokeDashArray()函數是PHP中的一個內置函數,用於獲取一個數組,該數組表示用於繪製路徑的虛線和間隙的模式。
用法:
array ImagickDraw::getStrokeDashArray( void )
參數:此函數不接受任何參數。
返回值:此函數成功返回包含筆劃破折號的數組,如果未設置,則返回空數組。
以下示例程序旨在說明PHP中的ImagickDraw::getStrokeDashArray()函數:
示例1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the stroke dash array
$array = $draw->getStrokeDashArray();
print("<pre>".print_r($array, true)."</pre>");
?>
輸出:
Array // Empty array which is the default value ( )
示例2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the stroke dash array
$draw->setStrokeDashArray([20, 5, 20, 5, 5, 5, ]);
// Get the stroke dash array
$array = $draw->getStrokeDashArray();
print("<pre>".print_r($array, true)."</pre>");
?>
輸出:
Array ( [0] => 20 [1] => 5 [2] => 20 [3] => 5 [4] => 5 [5] => 5 )
示例3:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// 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 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
相關用法
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
- PHP ImagickDraw color()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
- PHP ImagickDraw pathMoveToRelative()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getStrokeDashArray() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。