PHP | GmagickDraw ellipse() function
Last Updated :
23 Jan, 2020
The GmagickDraw::ellipse() function is an inbuilt function in PHP which is used to draw an ellipse on the image.
Syntax:
GmagickDraw GmagickDraw::ellipse( float $ox,
float $oy, float $rx, float $ry,
float $start, float $end )
Parameters: This function accepts six parameters as mentioned above and described below:
- $ox: It specifies the x-coordinate of the ellipse.
- $oy: It specifies the y-coordinate of the ellipse.
- $rx: It specifies the x-radius of the ellipse.
- $ry: It specifies the y-radius of the ellipse.
- $start: It specifies the start point of the ellipse.
- $end: It specifies the end point of the ellipse.
Return Value: This function returns an GmagickDraw object on success.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::ellipse() function in PHP:
Program 1 (Simple ellipse):
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( '#0E0E0E' );
$draw ->rectangle(-10, -10, 800, 400);
$draw ->setFillColor( '#3D99D4' );
$draw ->setStrokeWidth(5);
$draw ->ellipse(125, 70, 100, 50, 0, 360);
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Program 2 (Stroked ellipse):
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( '#0E0E0E' );
$draw ->rectangle(-10, -10, 800, 400);
$draw ->setFillColor( 'blue' );
$draw ->setstrokecolor( 'green' );
$draw ->setStrokeWidth(5);
$draw ->ellipse(225, 70, 150, 50, 0, 360);
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.ellipse.php
Share your thoughts in the comments
Please Login to comment...