PHP | ImagickDraw setStrokeDashArray() Function
Last Updated :
20 Dec, 2019
The ImagickDraw::setStrokeDashArray() function is an inbuilt function in PHP which is used to set the pattern of dashes and gaps used to stroke paths. In case of odd number of values, the list of values is repeated to yield an even number of values. To remove an existing dash array, pass a zero number_elements argument or null dash_array.
Syntax:
bool ImagickDraw::setStrokeDashArray( array $dashArray )
Parameters: This function accepts a single parameter $dashArray which holds the stroke dash.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickDraw::setStrokeDashArray() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$draw ->setStrokeDashArray([80, 5, 2, 5, 15, 51, ]);
$array = $draw ->getStrokeDashArray();
print ( "<pre>" .print_r( $array , true). "</pre>" );
?>
|
Output:
Array
(
[0] => 80
[1] => 5
[2] => 2
[3] => 5
[4] => 15
[5] => 51
)
Program 2:
<?php
$draw = new ImagickDraw();
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'black' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'black' );
$draw ->setStrokeColor( 'cyan' );
$draw ->setStrokeDashArray([2, 1, 3]);
$draw ->ellipse(400, 100, 150, 70, 60, 900);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.setstrokedasharray.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...