當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例


ImagickDraw::getStrokeMiterLimit()函數是PHP中的一個內置函數,用於獲取斜接限製。當兩個線段以銳角相遇時,斜接點的延伸範圍將遠遠超過撫摸路徑的線的厚度。

用法:

int ImagickDraw::getStrokeMiterLimit( void )

參數:此函數不接受任何參數。


返回值:該函數返回一個包含斜接限製的整數值。

異常:該函數在錯誤時引發ImagickException。

下麵給出的程序說明了PHP中的ImagickDraw::getStrokeMiterLimit()函數:

示例1:

<?php 
  
// Create a new ImagickDraw object 
$draw = new ImagickDraw(); 
    
// Get the stroke miter limit 
$miterLimit = $draw->getStrokeMiterLimit(); 
echo $miterLimit; 
?>

輸出:

10

示例2:

<?php 
  
// Create a new ImagickDraw object 
$draw = new ImagickDraw(); 
  
// Create a new imagick object 
$imagick = new Imagick(); 
  
// Create a image on imagick object 
$imagick->newImage(800, 250, 'white'); 
  
// Create a new ImagickDraw object 
$draw = new ImagickDraw(); 
  
// Set the stroke color 
$draw->setStrokeColor('green'); 
  
// Set the stroke opacity 
$draw->setStrokeOpacity(0.6); 
  
// Set the fill color 
$draw->setFillColor('white'); 
  
// Set the stroke width 
$draw->setStrokeWidth(10); 
  
// Set the stroke Line Join 
$draw->setStrokeLineJoin(Imagick::LINEJOIN_MITER); 
  
// Set the stroke miter limit 
$draw->setStrokeMiterLimit(0); 
  
// Create a polygon 
$draw->polygon([ 
    ['x' => 100, 'y' => 60], 
    ['x' => 60, 'y' => 80], 
    ['x' => 400, 'y' => 100] 
]); 
  
// Set the font size 
$draw->setFontSize(20); 
  
// Decrease the stroke width so that text can be printed 
$draw->setStrokeWidth(1); 
  
// Print the text 
$draw->annotation(450, 100, 'The strokeMiterLimit here is '
                             . $draw->getStrokeMiterLimit()); 
  
// Set the stroke width back to 10 
$draw->setStrokeWidth(10); 
  
// Set the stroke miter limit 
$draw->setStrokeMiterLimit(40); 
  
// Create a polygon 
$draw->polygon([ 
    ['x' => 100, 'y' => 160], 
    ['x' => 60, 'y' => 180], 
    ['x' => 400, 'y' => 180] 
]); 
  
// Decrease the stroke width so that text can be printed 
$draw->setStrokeWidth(1); 
  
// Print the text 
$draw->annotation(450, 180, 'The strokeMiterLimit here is ' 
                             . $draw->getStrokeMiterLimit()); 
  
// Render the draw commands 
$imagick->drawImage($draw); 
  
// Show the output 
$imagick->setImageFormat('png'); 
header("Content-Type: image/png"); 
echo $imagick->getImageBlob(); 
?>

輸出:

參考: https://www.php.net/manual/en/imagickdraw.getstrokemiterlimit.php



相關用法


注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw getStrokeMiterLimit() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。