PHP | GmagickDraw rotate() Function
Last Updated :
28 Jan, 2020
The GmagickDraw::rotate() function is an inbuilt function in PHP which is used to apply the specified rotation to the current coordinate space.
Syntax:
GmagickDraw GmagickDraw::rotate( array $coordinates_array )
Parameters: This function accepts a single parameter $coordinates_array which is used to hold the value of degree of rotation.
Return Value: This function returns GmagickDraw object on success.
Exceptions: This function throws GmagickDrawException on error.
Used Image: For canvas area.
Below given programs illustrates the GmagickDraw::rotate() function in PHP:
Program 1: In this example we will rotate the rectangle.
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->rectangle(-100, -1000, 800, 400);
$draw ->setFillColor( 'white' );
$draw ->setstrokecolor( 'blue' );
$draw ->rotate(4);
$draw ->setStrokeWidth(5);
$draw ->rectangle(100, 20, 400, 100);
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Program 2: In this example we will rotate a text.
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->rectangle(-100, -1000, 800, 400);
$draw ->setfontsize(25);
$draw ->setstrokecolor( 'blue' );
$draw ->rotate(40);
$draw ->annotate(20, -50, 'GeeksforGeeks' );
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.rotate.php
Share your thoughts in the comments
Please Login to comment...