PHP | GmagickDraw arc() Function
Last Updated :
31 Jan, 2020
The GmagickDraw::arc() function is an inbuilt function in PHP which is used to draw an arc falling within a specified bounding rectangle on the image.
Syntax:
GmagickDraw GmagickDraw::arc( float $sx, float $sy,
float $ex, float $ey, float $sd, float $ed )
Parameters: This function accept six parameters as mentioned above and described below:
- $sx: It specifies the starting x-ordinate of rectangle.
- $sy: It specifies the starting y-ordinate of rectangle.
- $ex: It specifies the ending x-ordinate of rectangle.
- $ey: It specifies the ending y-ordinate of rectangle.
- $sd: It specifies the starting degrees of rotation.
- $ed: It specifies the ending degrees of rotation.
Return Value: This function returns GmagickDraw object on success.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::arc() function in PHP:
Used Image:
Program 1 (Drawing arc from scratch):
PHP
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( 'white' );
$draw ->rectangle(0, 0, 800, 400);
$draw ->setFillColor( 'white' );
$draw ->setstrokecolor( 'black' );
$draw ->setStrokeWidth(5);
$draw ->arc(60, -60, 460, 170, 0, 200);
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Program 2 (Drawing arc on a image):
php
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( 'red' );
$draw ->setstrokecolor( 'green' );
$draw ->setStrokeWidth(5);
$draw ->arc(160, -60, 360, 170, 50, 200);
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.arc.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...