PHP | ImagickDraw getFillOpacity() Function
Last Updated :
23 Dec, 2019
The ImagickDraw::getFillOpacity() function is an inbuilt function in PHP which is used to get the opacity used when drawing using the fill color or fill texture. Fully opaque is 1 and fully transparent is 0.
Syntax:
float ImagickDraw::getFillOpacity( void )
Parameters: This function doesn’t accept any parameter.
Return Value: This function returns an float value containing the opacity.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickDraw::getFillOpacity() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$fillOpacity = $draw ->getFillOpacity();
echo $fillOpacity ;
?>
|
Output:
1 // which is the default value.
Program 2:
<?php
$draw = new ImagickDraw();
$draw ->setFillOpacity(0.6);
$fillOpacity = $draw ->getFillOpacity();
echo $fillOpacity ;
?>
|
Output:
0.6
Program 3:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'black' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'yellow' );
$draw ->setFontSize(20);
$draw ->annotation(50, 100, 'The fill opacity here is '
. $draw ->getFillOpacity());
$draw ->setFillOpacity(0.4);
$draw ->annotation(50, 200, 'The fill opacity here is '
. $draw ->getFillOpacity());
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.getfillopacity.php
Share your thoughts in the comments
Please Login to comment...