Open In App

PHP | ImagickDraw pathEllipticArcRelative() Function

Improve
Improve
Like Article
Like
Save
Share
Report

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

Syntax:

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

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 programs illustrate the ImagickDraw::pathEllipticArcRelative() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, '#7441e0');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
$draw->setFillColor('#2fceeb');
  
// Set the stroke color
$draw->setStrokeColor('#c27230');
  
// Set the stroke width
$draw->setStrokeWidth(15);
  
// Draw elliptic arc
$draw->pathStart();
$draw->pathEllipticArcRelative(120, 9250,
               210, false, true, 300, 400);
$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();
?>


Output:

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, '#7441e0');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
$draw->setFillColor('#2fceeb');
  
// Set the stroke color
$draw->setStrokeColor('#c27230');
  
// Set the stroke width
$draw->setStrokeWidth(15);
  
// Draw elliptic arc
$draw->pathStart();
$draw->pathEllipticArcRelative(120,
         50, 10, true, true, 300, 400);
$draw->pathFinish();
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

Reference: https://www.php.net/manual/en/imagickdraw.pathellipticarcrelative.php



Last Updated : 20 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads