PHP | ImagickDraw setStrokeMiterLimit() Function

The ImagickDraw::setStrokeMiterLimit() function is an inbuilt function in PHP which is used to specify the miter limit of stroke. When two line segments are meet at a sharp angle and miter joins have been specified for ‘lineJoin’, it is possible for the miter to extend far beyond the thickness of the line stroking the path. The miterLimit’ imposes a limit on the ratio of the miter length to the ‘lineWidth’.

Syntax:

bool ImagickDraw::setStrokeMiterLimit( $miterlimit )

Parameters: This function accepts a single parameter $miterlimit which is used to hold the value of miter limit as integer type.



Return Value: This function does not return any value.

Below programs illustrate the ImagickDraw::setStrokeMiterLimit() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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();
?>

chevron_right


Output:
setStrokeMiterLimit

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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();
?>

chevron_right


Output:
setStrokeMiterLimit

Reference: http://php.net/manual/en/imagickdraw.setstrokemiterlimit.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.