PHP | ImagickDraw setStrokeDashOffset() Function
Last Updated :
20 Dec, 2019
The ImagickDraw::setStrokeDashOffset() function is an inbuilt function in PHP which is used to set the offset into the dash pattern to start the dash.
Syntax:
bool ImagickDraw::setStrokeDashOffset( float $dash_offset )
Parameters: This function accepts a single parameter $dash_offset which holds the dash offset.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the ImagickDraw::setStrokeDashOffset() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$draw ->setStrokeDashOffset(5);
$offset = $draw ->getStrokeDashOffset();
echo $offset ;
?>
|
Output:
5
Program 2:
<?php
$draw = new ImagickDraw();
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'black' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'black' );
$draw ->setStrokeColor( 'white' );
$draw ->setStrokeDashArray([15, 5, 15]);
$draw ->setStrokeDashOffset(20);
$draw ->ellipse(400, 100, 70, 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.setstrokedashoffset.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...