Change language

PHP ImagickDraw rectangle () Function

|
Syntax:
bool ImagickDraw::rectangle-method/">rectangle ($x1, $y1, $x2, $y2)
Parameters:This function takes four parameters as above and described below:
  • $x1:This parameter takes the value of the left x coordinate top corner.
  • $y1:this parameter takes the value of the y coordinate of the top left corner.
  • $x2:this parameter takes the value of the x coordinate in the lower right corner.
  • $y2:this parameter takes the value of the y coordinate in the lower right corner.
Return Value:This function returns TRUE on success.The following program illustrates the ImagickDraw rectangle-method/">rectangle() functionin PHP:
Program:
// require_once (’ vendor / autoload.php ’); 
// Create ImagickDraw object $draw = new ImagickDraw(); $draw -> setStrokeColor ( ’Green’ ); $draw -> setFillColor ( ’Red’ ); $draw -> setStrokeWidth (7); $draw -> rectangle-method/">rectangle (40, 30, 200, 260);  
// Create an image object to draw
// commands can be submitted in $image = new Imagick(); $image -> newImage (300, 300, ’White’ ); $image -> setImageFormat ( "png" );  
// Render drawing commands in ImagickDraw
// into the image. $image -> drawImage ( $draw ) ;  
// Send image to browser header ( "Content-Type: image / png" ); echo $image -> getImageBlob(); ?>
Output:
Link:http://php.net/manual/en/imagickdraw.rectangle-method/">rectangle.php