PHP | GmagickPixel __construct() Function
Last Updated :
29 Jan, 2020
The GmagickPixel::__construct() function is an inbuilt function in PHP which is used to construct an GmagickPixel object. If a color is specified, the object is constructed and then initialized with that color before being returned.
Syntax:
GmagickPixel GmagickPixel::__construct( string $color )
Parameters: This function accepts a single parameter $color which is optional and holds the color.
Return Value: This function returns GmagickPixel object on success.
Exceptions: This function throws GmagickPixelException on error.
Below given programs illustrate the GmagickPixel::__construct() function in PHP:
Program 1 (Without color parameter):
<?php
$gmagickPixel = new GmagickPixel();
$color = $gmagickPixel ->getcolor();
echo $color ;
?>
|
Output:
rgb(0, 0, 0)
Program 2 (With color parameter):
<?php
$gmagickPixel = new GmagickPixel( '#ccb062' );
$color = $gmagickPixel ->getcolor();
echo $color ;
?>
|
Output:
rgb(52428, 45232, 25186)
Reference: https://www.php.net/manual/en/gmagickpixel.construct.php
Share your thoughts in the comments
Please Login to comment...