Open In App

PHP | GmagickDraw arc() Function

Last Updated : 31 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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
  
// 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();
?>


Output: 

 

Program 2 (Drawing arc on a image): 

php




<?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();
?>


Output: 

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



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads