PHP | ImagickDraw resetVectorGraphics() Function
Last Updated :
30 Dec, 2019
The ImagickDraw::resetVectorGraphics() function is an inbuilt function in PHP which is used to reset the vector graphics. Vector graphics contain all the draw commands. Resetting the vector graphics will delete all the old commands. Another use of this function is when you want to reset all the fill colors to default color i.e. black you can use this function.
Syntax:
bool ImagickDraw::resetVectorGraphics( void )
Parameters: This function doesn’t accept any parameter.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickDraw::resetVectorGraphics() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'cyan' );
$draw = new ImagickDraw();
$draw ->annotation(400, 200, 'Hello' );
$draw ->resetVectorGraphics();
$draw ->setFillColor( 'green' );
$draw ->rectangle(0, 0, 200, 900);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'gray' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'white' );
$draw ->setFontSize(40);
$draw ->annotation(500, 100, 'GeeksforGeeks' );
$imagick ->drawImage( $draw );
$draw ->resetVectorGraphics();
$draw ->circle(300, 200, 300, 20);
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.resetvectorgraphics.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...