📜  PHP | imagickdraw getStrokeMiterLimit()函数

📅  最后修改于: 2022-05-13 01:56:47.441000             🧑  作者: Mango

PHP | imagickdraw getStrokeMiterLimit()函数

ImagickDraw::getStrokeMiterLimit()函数是PHP中的一个内置函数,用于获取斜接限制。当两条线段以锐角相交时,斜接连接会延伸到远远超出抚摸路径的线的厚度。

句法:

int ImagickDraw::getStrokeMiterLimit( void )

参数:此函数不接受任何参数。

返回值:此函数返回一个包含斜接限制的整数值。

异常:此函数在出错时抛出 ImagickException。

下面给出的程序说明了PHP中的ImagickDraw::getStrokeMiterLimit()函数

方案一:

getStrokeMiterLimit();
echo $miterLimit;
?>

输出:

10

方案二:

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