PHP | GmagickDraw getfillcolor() function

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php 
// Create a new GmagickDraw object 
$draw = new GmagickDraw(); 
  
// Set the fill color
$draw->setfillcolor('blue');
    
// Get the fill color 
$colorPixel = $draw->getfillcolor(); 
$color = $colorPixel->getcolor();
echo $color
?> 

chevron_right


Output:

rgb(0, 0, 65535)

Program-2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
  
// Create a GmagickDraw object
$draw = new GmagickDraw();
  
// Set the color
$draw->setFillColor('#0E0E0E');
  
// Draw rectangle for background
$draw->rectangle(-10, -10, 800, 400);
  
// Set the fill color
$draw->setFillColor('green');
  
// Set the font size
$draw->setFontSize(20);
  
// Annotate a text
$draw->annotate(50, 50, 'The fill color here is ' . $draw->getFillColor()->getcolor());
  
// Set the fill color
$draw->setFillColor('red');
  
// Annotate a text
$draw->annotate(50, 100, 'The fill color here is ' . $draw->getFillColor()->getcolor());
  
// Use of drawimage functeannotate
$gmagick->drawImage($draw);
  
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>

chevron_right


Output:

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