当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。