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


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


ImagickDraw::setStrokeMiterLimit()函數是PHP中的一個內置函數,用於指定筆劃的斜接限製。當兩條線段以銳角相交並且為“ lineJoin”指定了斜接時,斜接可能會延伸到遠遠超出行程路徑的線的粗細。 mitreLimit”對斜接長度與“ lineWidth”的比率施加了限製。

用法:

bool ImagickDraw::setStrokeMiterLimit( $miterlimit )

參數:該函數接受單個參數$miterlimit,該參數用於將斜接限製值保留為整數類型。


返回值:該函數不返回任何值。

以下示例程序旨在說明PHP中的ImagickDraw::setStrokeMiterLimit()函數:

程序1:

<?php 
  
// require_once('path/vendor/autoload.php'); 
  
// Create an ImagickDraw object 
$draw = new \ImagickDraw(); 
  
// Set the Stroke Opacity 
$draw->setStrokeOpacity(1); 
  
// Set the Stroke Color 
$draw->setStrokeColor('Black'); 
  
// Set the Stroke Opacity 
$draw->setStrokeOpacity(0.6); 
  
// Set the Stroke Width   
$draw->setStrokeWidth(4); 
  
// Set the image filled color  
$draw->setFillColor('lightgreen'); 
      
// Set the Stroke Miter Limit  
$draw->setStrokeMiterLimit(40 * 12); 
$points = [ 
        ['x' => 50 * 6, 'y' => 10 * 5], 
        ['x' => 20 * 7, 'y' => 30 * 5],  
        ['x' => 60 * 8, 'y' => 50 * 5],  
        ['x' => 70 * 3, 'y' => 15 * 5], 
    ]; 
  
// Draw the polygon  
$draw->polygon($points); 
  
// Create new Imagick object  
$image = new \Imagick(); 
  
// Set the dimensions of the image 
$image->newImage(500, 300, 'white'); 
  
// Set the image format 
$image->setImageFormat("png"); 
  
// Draw the image 
$image->drawImage($draw); 
header("Content-Type: image/png"); 
  
// Display the Image 
echo $image->getImageBlob(); 
?>

輸出:
setStrokeMiterLimit

程序2:

<?php 
   
// require_once('path/vendor/autoload.php'); 
   
// Create a ImagickDraw object to draw into. 
$draw = new ImagickDraw(); 
   
// Set the Stroke Width 
$draw->setStrokeWidth(5); 
   
// Set the Stroke Miter Limit 
$draw->setStrokeMiterLimit(50 * 15); 
   
// Set the Stroke Color 
$draw->setStrokeColor('black'); 
   
// Set the image filled color 
$draw->setFillColor('red'); 
$points = [['x' => 40 * 5, 'y' => 10 * 5], 
          ['x' => 70 * 5, 'y' => 50 * 5],  
          ['x' => 60 * 5, 'y' => 15 * 5], ]; 
   
// Draw the polygon  
$draw->polygon($points); 
   
// Set the image filled color 
$draw->setFillColor('green'); 
   
// Set the translation points 
$draw->translate(10, 30); 
$points = [['x' => 40 * 5, 'y' => 10 * 5], 
           ['x' => 70 * 5, 'y' => 50 * 5],  
           ['x' => 60 * 5, 'y' => 15 * 5], ]; 
   
// Draw the polygon 
$draw->polygon($points); 
   
// Set the image filled color 
$draw->setFillColor('blue'); 
   
// Set the translation points 
$draw->translate(10, 30); 
$points = [['x' => 40 * 5, 'y' => 10 * 5],  
           ['x' => 70 * 5, 'y' => 50 * 5],  
           ['x' => 60 * 5, 'y' => 15 * 5], ]; 
   
// Draw the polygon 
$draw->polygon($points); 
   
// Set the image filled color 
$draw->setFillColor('yellow'); 
   
// Set the translation points 
$draw->translate(10, 30); 
$points = [['x' => 40 * 5, 'y' => 10 * 5],  
           ['x' => 70 * 5, 'y' => 50 * 5],  
           ['x' => 60 * 5, 'y' => 15 * 5], ]; 
   
// Draw the polygon 
$draw->polygon($points); 
   
// Create new Imagick object  
$image = new Imagick(); 
   
// Set the dimensions of the image 
$image->newImage(400, 400, 'white'); 
   
// Set the image format 
$image->setImageFormat("png"); 
    
// Draw the image  
$image->drawImage($draw); 
header("Content-Type: image/png"); 
   
// Display the image 
echo $image->getImageBlob(); 
?>

輸出:
setStrokeMiterLimit

參考: http://php.net/manual/en/imagickdraw.setstrokemiterlimit.php



相關用法


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