PHP | ImagickDraw getVectorGraphics() Function
The ImagickDraw::getVectorGraphics() function is an inbuilt function in PHP which is used to get string containing vector graphics. In simple words, it contains all the draw commands in the form of strings. It is also used to extract comments from a ImagickDraw object. It returns a large string containing so much unwanted data which can be trimmed using PHP substr() function.
Syntax:
string ImagickDraw::getVectorGraphics( void )
Parameters: This function doesn’t accepts any parameters.
Return Value: This function returns an string value containing the vector graphics.
Below programs illustrate the ImagickDraw::getVectorGraphics() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$vectorGraphics = $draw ->getVectorGraphics();
$vectorGraphics = substr ( $vectorGraphics , 807);
echo $vectorGraphics ;
?>
|
Output:
Empty string because of no commands.
Program 2:
<?php
$draw = new ImagickDraw();
$draw ->setTextUnderColor( 'green' );
$draw ->setFontSize(30);
$draw ->line(30, 40, 100, 300);
$vectorGraphics = $draw ->getVectorGraphics();
$vectorGraphics = substr ( $vectorGraphics , 806);
echo $vectorGraphics ;
?>
|
Output:
text-undercolor '#000080800000' font-size 30 line 30 40 100 300
Program 3:
<?php
$draw = new ImagickDraw();
$draw ->comment( 'GeeksforGeeks' );
$graphics = $draw ->getVectorGraphics();
$comment = substr ( $graphics , 807);
echo $comment ;
?>
|
Output:
GeeksforGeeks
Reference: https://www.php.net/manual/en/imagickdraw.getvectorgraphics.php
Last Updated :
17 Dec, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...