Open In App

PHP | ImagickDraw getClipRule() Function

The ImagickDraw::getClipRule() function is an inbuilt function in PHP which is used to get the current polygon fill rule to be used by the clipping path.

Syntax:



int ImagickDraw::getClipRule( void )

Parameters: This function doesn’t accept any parameter.

Return Value: This function returns an integer value corresponding to one of FILLRULE constants.



List of FILLRULE constants are given below:

Exceptions: This function throws ImagickException on error.

Below given programs illustrate the ImagickDraw::getClipRule() function in PHP:

Program 1:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Get the clipRule
$clipRule = $draw->getClipRule();
echo $clipRule;
?>

Output:

1 // which is the default value.

Program 2:




<?php
     
// Create a new imagick object
$imagick = new Imagick();
     
// Create a image on imagick object
$imagick->newImage(500, 250, 'green');
     
// Create a new ImagickDraw object
$draw = new ImagickDraw();
     
$draw->setClipRule(imagick::FILLRULE_EVENODD);
   
$draw->setFontSize(24);
   
$draw->annotation(160, 125, 
                  'The clipRule is '
                  . $draw->getClipRule() . '.');
     
// Render the draw commands
$imagick->drawImage($draw);
     
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

Output:


Article Tags :