Wednesday, September 25, 2024
Google search engine
HomeLanguagesPHP | GmagickDraw gettextdecoration() Function

PHP | GmagickDraw gettextdecoration() Function

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('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 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

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

Recent Comments