Thursday, July 4, 2024
HomeLanguagesPhpPHP | ImagickDraw getStrokeLineJoin() Function

PHP | ImagickDraw getStrokeLineJoin() Function

The ImagickDraw::getStrokeLineJoin() function is an inbuilt function in PHP which is used to get the shape to be used at the corners of paths when they are stroked. This usually impacts the outer edges and turns of the stroke.

Syntax:

int ImagickDraw::getStrokeLineJoin( void )

Parameters: This function doesn’t accepts any parameters.

Return Value: This function returns an integer value corresponding to one of LINEJOIN constants.

List of LINEJOIN constants are given below:

  • imagick::LINEJOIN_UNDEFINED (0)
  • imagick::LINEJOIN_MITER (1)
  • imagick::LINEJOIN_ROUND (2)
  • imagick::LINEJOIN_BEVEL (3)

Exceptions: This function throws ImagickException on error.

Below programs illustrate the ImagickDraw::getStrokeLineJoin() function in PHP:

Program 1:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
    
// Get the stroke line join
$lineJoin = $draw->getStrokeLineJoin();
echo $lineJoin;
?>


Output:

1 // Which corresponds to imagick::LINEJOIN_MITER

Program 2:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Set the stroke line join
$draw->setStrokeLineJoin(3);
  
// Get the stroke line join
$lineJoin = $draw->getStrokeLineJoin();
echo $lineJoin;
?>


Output:

3 // Which corresponds to imagick::LINEJOIN_BEVEL

Program 3:




<?php
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
    
// Create a new imagick object
$imagick = new Imagick();
    
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
    
// Create a new ImagickDraw object
$draw = new ImagickDraw();
    
// Set the fill color
$draw->setFillColor('white');
    
// Set the color of stroke
$draw->setStrokeColor('blue');
  
// Set the stroke width
$draw->setStrokeWidth(4);
    
// Set the font size
$draw->setFontSize(25);
   
 // Set the stroke dash array
$draw->setStrokeDashArray([20]);
   
// Draw a rectangle
$draw->rectangle(100, 50, 225, 175);
    
// Annotate a text
$draw->annotation(10, 220, 'The strokeLineJoin here is '
        . $draw->getStrokeLineJoin());
   
// Set the stroke line join
$draw->setStrokeLineJoin(2);
    
// Draw a rectangle
$draw->rectangle(500, 50, 625, 175);
    
// Annotate a text
$draw->annotation(400, 220, 'The strokeLineJoin here is '
        . $draw->getStrokeLineJoin());
    
// Render the draw commands
$imagick->drawImage($draw);
    
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

Reference: https://www.php.net/manual/en/imagickdraw.getstrokelinejoin.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!

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments