PHP | GmagickDraw setstrokecolor() Function

The GmagickDraw ::setstrokecolor() function is an inbuilt function in PHP which is used to set the color used for stroking object outlines.

Syntax:

public GmagickDraw::setstrokecolor( $color ) : GmagickDraw

Parameters: This function accepts single parameter $color which is used to hold the color value.

Return Value: This function returns the GmagickDraw object on success.

Below programs illustrates the GmagickDraw ::setstrokecolor() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// require_once('path/vendor/autoload.php');
   
// Create an GmagickDraw object
$draw = new \GmagickDraw ();
   
// Set stroke opacity
$draw->setStrokeOpacity(1);
   
// Set stroke color
$draw->setStrokeColor('Black');
   
// Set stroke opacity
$draw->setStrokeOpacity(0.8);
   
// Set stroke width
$draw->setStrokeWidth(10);
   
// Set Stroke Line Join
$draw->setStrokeLineJoin(Gmagick::LINEJOIN_ROUND);
   
// Set Fill Color
$draw->setFillColor('lightgreen');
       
// Set Stroke Miter Limit
$draw->setStrokeMiterLimit(40 * 12);
   
$points = [
        ['x' => 50 * 6, 'y' => 10 * 5],
        ['x' => 20 * 7, 'y' => 30 * 5], 
        ['x' => 60 * 8, 'y' => 50 * 5], 
        ['x' => 70 * 3, 'y' => 15 * 5],
    ];
   
// Draw a polygon
$draw->polygon($points);
   
// Create a new Gmagick object
$image = new \Gmagick();
   
// Set image dimensions
$image->newImage(500, 300, 'white');
   
// Set the image format 
$image->setImageFormat("png");
   
// Draw the image
$image->drawImage($draw);
header("Content-Type: image/png");
   
// Display the image
echo $image->getImageBlob();
?>

chevron_right


Output:

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// require_once('path/vendor/autoload.php');
   
// Create an GmagickDraw object 
$draw = new \GmagickDraw ();
   
// Set the stroke color
$draw->setStrokeColor('Green');
   
// Set Fill Color
$draw->setFillColor('Red');
   
// Set the stroke width
$draw->setStrokeWidth(7);
   
// Draw the rectangle
$draw->rectangle(40, 30, 200, 260);
   
// Create new Gmagick object 
$image = new \Gmagick();
   
// Set the image dimension
$image->newImage(300, 300, 'White');
   
// Set the image format
$image->setImageFormat("png");
   
// Draw the image
$image->drawImage($draw);
header("Content-Type: image/png");
   
// Display the image
echo $image->getImageBlob();
?>

chevron_right


Output:

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



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.