Open In App

PHP | GmagickDraw gettextdecoration() Function

Last Updated : 29 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The GmagickDraw::gettextdecoration() function is an inbuilt function in PHP which is used to get the decoration applied when annotating with text.

Syntax:

int GmagickDraw::gettextdecoration( void )

Parameters: This function doesn’t accept any parameters.

Return Value: This function returns an integer value corresponding to one of DECORATION constants.
List of DECORATION constants are given below:

  • Gmagick::DECORATION_NO (0)
  • Gmagick::DECORATION_UNDERLINE (1)
  • Gmagick::DECORATION_OVERLINE (2)
  • Gmagick::DECORATION_LINETROUGH (3)

Exceptions: This function throws GmagickDrawException on error.

Below given programs illustrate the GmagickDraw::gettextdecoration() function in PHP:

Program 1:




<?php
  
// Create a new GmagickDraw object 
$draw = new GmagickDraw(); 
    
// Get the text decoration 
$textDecoration = $draw->gettextdecoration(); 
echo $textDecoration
?>


Output:

0 // Which is the default value

Program 2:




<?php
  
// Create a new GmagickDraw object 
$draw = new GmagickDraw(); 
  
// Set the text decoration
$draw->settextdecoration(3);
    
// Get the text decoration 
$textDecoration = $draw->gettextdecoration(); 
echo $textDecoration
?>


Output:

3

Used Image:

Program 3:




<?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 font size
$draw->setfontsize(30);
  
// Set the fill color
$draw->setFillColor('white');
  
// Set the text decoration to overline
$draw->settextdecoration(2);
  
// Get the text decoration
$textDecoration = $draw->gettextdecoration();
  
// Annotate a text
$draw->annotate(50, 100, 'The text decoration here is '
    . $textDecoration);
  
// 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.gettextdecoration.php



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads