ImagickDraw::getVectorGraphics()函數是PHP中的內置函數,用於獲取包含矢量圖形的字符串。簡單來說,它包含所有字符串形式的繪製命令。它還用於從ImagickDraw對象提取注釋。它返回一個很大的字符串,其中包含很多不需要的數據,可以使用PHP substr()函數進行修剪。
用法:
string ImagickDraw::getVectorGraphics( void )
參數:此函數不接受任何參數。
返回值:此函數返回包含矢量圖形的字符串值。
以下示例程序旨在說明PHP中的ImagickDraw::getVectorGraphics()函數:
示例1:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Get the vector graphics
$vectorGraphics = $draw->getVectorGraphics();
// Trim unwanted part
$vectorGraphics = substr($vectorGraphics, 807);
echo $vectorGraphics;
?>
輸出:
Empty string because of no commands.
示例2:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Add some draw commands
$draw->setTextUnderColor('green');
$draw->setFontSize(30);
$draw->line(30, 40, 100, 300);
// Get the vector graphics
$vectorGraphics = $draw->getVectorGraphics();
// Trim unwanted part
$vectorGraphics = substr($vectorGraphics, 806);
echo $vectorGraphics;
?>
輸出:
text-undercolor '#000080800000' font-size 30 line 30 40 100 300
示例3:
<?php
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Add comment
$draw->comment('GeeksforGeeks');
// Get the vector graphics as string
$graphics = $draw->getVectorGraphics();
// Get comment from vector graphics
$comment = substr($graphics, 807);
echo $comment;
?>
輸出:
GeeksforGeeks
參考: https://www.php.net/manual/en/imagickdraw.getvectorgraphics.php
相關用法
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw color()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getVectorGraphics() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。