PHP | GmagickDraw getfillcolor() function
Last Updated :
23 Jan, 2020
The GmagickDraw::getfillcolor() function is an inbuilt function in PHP which is used to get the fill color used for drawing filled objects.
Syntax:
GmagickPixel GmagickDraw::getfillcolor( void )
Parameters:This function doesn’t accept any parameter.
Return Value: This function returns GmagickPixel fill color used for drawing filled objects.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::getfillcolor() function in PHP:
Program-1:
<?php
$draw = new GmagickDraw();
$draw ->setfillcolor( 'blue' );
$colorPixel = $draw ->getfillcolor();
$color = $colorPixel ->getcolor();
echo $color ;
?>
|
Output:
rgb(0, 0, 65535)
Program-2:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( '#0E0E0E' );
$draw ->rectangle(-10, -10, 800, 400);
$draw ->setFillColor( 'green' );
$draw ->setFontSize(20);
$draw ->annotate(50, 50, 'The fill color here is ' . $draw ->getFillColor()->getcolor());
$draw ->setFillColor( 'red' );
$draw ->annotate(50, 100, 'The fill color here is ' . $draw ->getFillColor()->getcolor());
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.getfillcolor.php
Share your thoughts in the comments
Please Login to comment...