Skip to content
Related Articles

Related Articles

PHP | GmagickDraw settextdecoration() Function
  • Last Updated : 28 Jan, 2019

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

Syntax:

public GmagickDraw::settextdecoration( $decoration ) : GmagickDraw

Parameters: This function accepts single parameter $decoration which is used to hold the value of DECORATION_ constant.
The list of DECORATION_ constants are given below:

  • Gmagick ::DECORATION_NO (integer)
  • Gmagick ::DECORATION_UNDERLINE (integer)
  • Gmagick ::DECORATION_OVERLINE (integer)
  • Gmagick ::DECORATION_LINETROUGH (integer)

Return Value: This function returns the GmagickDraw object on success

Below programs illustrate the GmagickDraw ::settextdecoration() function in PHP:



Program 1:




<?php
  
// Create an GmagickDraw  object
$draw = new GmagickDraw ();
  
// Set the image filled color 
$draw->setFillColor('green');
  
// Set the font size
$draw->setFontSize(60);
  
// Set the Text Decoration
$draw->setTextDecoration(4);
  
// Set the text to be added
$draw->annotation(50, 75, "GeeksForGeeks");
   
// Create new Gmagick Object
$gmagick = new Gmagick ();
  
// Set image dimensions
$gmagick ->newImage(500, 160, 'white');
  
// Set the image format
$gmagick ->setImageFormat("png");
  
// Draw the image
$gmagick ->drawImage($draw);
header("Content-Type: image/png");
  
// Display the image
echo $gmagick ->getImageBlob();
?>

Output:
setTextDecoration

Program 2:




<?php
  
// Create an GmagickDraw object
$draw = new GmagickDraw ();
  
// Set the image filled color 
$draw->setFillColor('yellow');
  
// Set the font size
$draw->setFontSize(20);
  
// Set the TextDecoration() function
// Text is Upperline
$draw->setTextDecoration(3);
// Set the text to be added
$draw->annotation(50, 75, "A Computer Science Portal For Geeks!");
  
// Create new Gmagick Object 
$gmagick = new Gmagick ();
  
// Set the image dimensions
$gmagick ->newImage(500, 160, 'black');
  
// Set the image format
$gmagick ->setImageFormat("png");
  
// Draw the image
$gmagick ->drawImage($draw);
header("Content-Type: image/png");
  
// Display the image
echo $gmagick ->getImageBlob();
?>

Output:
setTextDecoration

Reference: http://php.net/manual/en/gmagickdraw.settextdecoration.php

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :