PHP | ImagickDraw pathEllipticArcAbsolute() Function

The ImagickDraw::pathEllipticArcAbsolute() function is an inbuilt function in PHP which is used to draw an elliptical arc from the current point to (x, y) using absolute coordinates.

Syntax:

bool ImagickDraw::pathEllipticArcAbsolute(
float $rx, float $ry, float $x_axis_rotation, 
bool $large_arc_flag, bool $sweep_flag, float $x, 
float $y )

Parameters: This function accepts seven parameters as mentioned above and described below:

  • $rx: It specifies the x-radius.
  • $ry: It specifies the y-radius
  • $x_axis_rotation: It specifies x-axis rotation
  • $large_arc_flag: It specifies whether to draw the larger of the available arcs.
  • $sweep_flag: It specifies whether to draw the arc matching a clock-wise rotation.
  • $x: It specifies the x-coordinate.
  • $y: It specifies the y-coordinate.

Return Value: This function returns TRUE on success.

Exceptions: This function throws ImagickException on error.



Below given programs illustrate the ImagickDraw::pathEllipticArcAbsolute() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, 'green');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
$draw->setFillColor('blue');
  
// Set the stroke color
$draw->setStrokeColor('red');
  
// Set the stroke width
$draw->setStrokeWidth(15);
  
// Draw elliptic arc
$draw->pathStart();
$draw->pathEllipticArcAbsolute(420, 250, 10, true, true, 40, 40);
$draw->pathClose();
$draw->pathFinish();
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

chevron_right


Output:

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, '#E57733');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the width of stroke
$draw->setStrokeWidth(1);
  
// Set the color of stroke
$draw->setStrokeColor('#E57733');
  
// Set the fill color
$draw->setFillColor('black');
  
// Set the fill rule
$draw->setFillRule(Imagick::FILLRULE_NONZERO);
  
// Draw a sunset cartoon
$draw->pathStart();
$draw->pathMoveToAbsolute(0, 100);
$draw->pathEllipticArcAbsolute(420, 400, 410, true, true, 0, 900);
$draw->pathMoveToAbsolute(300, 250);
$draw->pathEllipticArcAbsolute(420, 600, 410, true, true, 0, 900);
$draw->pathClose();
$draw->pathFinish();
$draw->setFillColor('yellow');
$draw->translate(30, 0);
$draw->circle(300, 100, 300, 150);
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

chevron_right


Output:

Reference: https://www.php.net/manual/en/imagickdraw.pathellipticarcabsolute.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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.