PHP | ImagickDraw setStrokeLineCap() Function
Last Updated :
07 Mar, 2024
The ImagickDraw::setStrokeLineCap() function is an inbuilt function in PHP which is used to set the shape to be used at the end of open subpaths when they are stroked.
Syntax:
bool ImagickDraw::setStrokeLineCap( int $linecap )
Parameters: This function accepts a single parameter $linecap which holds an integer value corresponding to one of LINECAP constants.
List of LINECAP constants are given below:
- imagick::LINECAP_UNDEFINED (0)
- imagick::LINECAP_BUTT (1)
- imagick::LINECAP_ROUND (2)
- imagick::LINECAP_SQUARE (3)
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the ImagickDraw::setStrokeLineCap() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$draw ->setStrokeLineCap(2);
$lineCap = $draw ->getStrokeLineCap();
echo $lineCap ;
?>
|
Output:
2 // Which corresponds to imagick::LINECAP_ROUND
Program 2:
<?php
$draw = new ImagickDraw();
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'grey' );
$draw = new ImagickDraw();
$draw ->setStrokeColor( 'red' );
$draw ->setStrokeWidth(3);
$draw ->setFontSize(25);
$draw ->setStrokeDashArray([20]);
$draw ->setStrokeLineCap(3);
$draw ->circle(250, 150, 330, 130);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...