Thursday, September 4, 2025
HomeLanguagesPHP | GmagickDraw getfillcolor() function

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:




<?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
?> 


Output:

rgb(0, 0, 65535)

Program-2:




<?php
// Create a new Gmagick object
$gmagick = new Gmagick('neveropen.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();
?>


Output:

Reference: https://www.php.net/manual/en/gmagickdraw.getfillcolor.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32262 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11857 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6696 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS