PHP | GmagickDraw arc() Function

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
   
// Create a GmagickDraw object
$draw = new GmagickDraw();
   
// Set the color
$draw->setFillColor('white');
   
// Function to draw rectangle
$draw->rectangle(0, 0, 800, 400);
   
// Set the fill color
$draw->setFillColor('white');
  
// Set the stroke color
$draw->setstrokecolor('black');
  
// Set the stroke width
$draw->setStrokeWidth(5); 
   
// Mark a arc
$draw->arc(60, -60, 460, 170, 0, 200);
   
// Use of drawimage function
$gmagick->drawImage($draw);
   
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>

chevron_right


Output: 

 

Program 2 (Drawing arc on a image): 

php

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
    
// Create a GmagickDraw object
$draw = new GmagickDraw();
    
// Set the fill color
$draw->setFillColor('red');
   
// Set the stroke color
$draw->setstrokecolor('green');
   
// Set the stroke width
$draw->setStrokeWidth(5); 
    
// Mark a arc
$draw->arc(160, -60, 360, 170, 50, 200);
    
// Use of drawimage function
$gmagick->drawImage($draw);
    
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>

chevron_right


Output: 

Reference: https://www.php.net/manual/en/gmagickdraw.arc.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.