PHP | GmagickDraw roundrectangle() Function
The GmagickDraw::roundrectangle() function is an inbuilt function in PHP which is used to draw a rounded rectangle.
Syntax:
public GmagickDraw::rectangle( $x1, $y1, $x2, $y2, $rx, $ry)
Parameters:This function accepts four parameters as mentioned above and described below:
- $x1: This parameter takes the value of x coordinate of the top left corner.
- $y1: This parameter takes the value of y coordinate of the top left corner.
- $x2: This parameter takes the value of x coordinate of the bottom right.
- $y2: This parameter takes the value of y coordinate of the bottom right.
- $ry: This parameter takes the value of radius of corner in vertical direction.
- $rx: This parameter takes the value of radius of corner in horizontal direction.
Return Value: This function returns GmagickDraw object on success.
Errors/Exceptions: This function throws GmagickException on error.
Below programs illustrate the GmagickDraw::roundrectangle() function in PHP:
Program 1:
<?php // Create a GmagickDraw object $draw = new GmagickDraw(); // Set the color $draw ->setFillColor( 'Green' ); // Set the width and height of image $draw ->setStrokeWidth(7); $draw ->setFontSize(72); // Function to draw roundrectangle $draw ->roundrectangle(20, 20, 380, 465, 50, 50); $gmagick = new Gmagick(); $gmagick ->newImage(500, 500, 'White' ); $gmagick ->setImageFormat( "png" ); // Use of drawimage function $gmagick ->drawImage( $draw ); // Display the output image header( "Content-Type: image/png" ); echo $gmagick ->getImageBlob(); ?> |
Output:
Program 2:
<?php // Create a GmagickDraw object $draw = new ImagickDraw(); // Set the color $draw ->setFillColor( 'Lightgreen' ); // Set the width and height of image $draw ->setStrokeWidth(7); $draw ->setFontSize(72); // Function to draw roundrectangle $draw ->roundrectangle(20, 20, 880, 465, 50, 50); $draw ->setFontSize(40); $draw ->setFillColor( 'Green' ); $gmagick = new Imagick(); $gmagick ->newImage(900, 500, 'White' ); $gmagick ->setImageFormat( "png" ); // Use of drawimage function $gmagick ->drawImage( $draw ); // Annotate Image $gmagick ->annotateImage( $draw , 5, 120, 0, ' w3wiki: A computer science portal' ); $gmagick ->annotateImage( $draw , 5, 220, 0, ' sarthak_ishu11' ); // Display the output image header( "Content-Type: image/png" ); echo $gmagick ->getImageBlob(); ?> |
Output:
Reference: http://php.net/manual/en/gmagickdraw.roundrectangle.php
Contact Us