Syntax:bool ImagickDraw::setStrokeAlpha ($opacity)
Parameters: This function takes opacity one parameter, which is used to specify the transparency of the stroke object. This is a floating point value, it ranges from 0 to 1.Returned value:This function does not return any value.The following programs illustrate function ImagickDraw::setStrokeAlpha()in PHP:Program 1: php
// require_once (’ path / vendor / autoload.php ’);
// Create Imagick Draw object
$draw
=
new
ImagickDraw();
// Set stroke color
$strokeColor
=
new
ImagickPixel (
’Green’
);
// Set the fill color
$fillColor
=
new
ImagickPixel (
’Red’
);
// Set stroke color
$draw
-> setStrokeColor (
’Green’
);
// Set fill color
$draw
-> setFillColor (
’Red’
);
// Set the stroke width
$draw
-> setStrokeWidth (5);
// Set the opacity of the stroke
$draw
-> setStrokeOpacity (0.5);
$smoothPointsSet
= [
[[
’x’
= > 10.0 * 5,
’y’
= > 10.0 * 5],
[
’x’
= > 30.0 * 5,
’y’
= > 90.0 * 5],
[
’x’
= > 25.0 * 5,
’y’
= > 10.0 * 5],
[
’x’
= > 50.0 * 5,
’y’
= > 50.0 * 5],]
];
foreach
(
$smoothPointsSet
as
$points
) {
$draw
-> bezier (
$points
);
}
// Create imagick object
$imagick
=
new
Imagick();
// Set image dimensions
$imagick
-> newImage (300, 300,
’White’
);
// Set image format
$imagick
-> setImageFormat (
"png"
);
// Draw image
$imagick
-> drawImage (
$draw
);
header (
"Content-Type: image / png"
);
// Show image
echo
$imagick
-> getImageBlob();
?>
Output: Program 2: < tbody> php
// require_once (’ path / vendor / autoload.php ’);
// Create an ImagickDraw object
$draw
=
new
ImagickDraw();
// Set the stroke color
$draw
-> setStrokeColor (
’Green’
);
// Set fill color
$draw
-> setFillColor (
’Red’
);
// Set the stroke width
$draw
-> setStrokeWidth (7);
// Set the opacity of the stroke
$draw
-> setStrokeOpacity (0.5);
// Draw a rectangle-method/">rectangle
$draw
-> rectangle-method/">rectangle (40, 30, 200, 260);
// Create an Imagick object
$image
=
new
Imagick();
// Set image dimensions
$image
-> newImage (250, 300,
’White’
);
// Set image format
$image
-> setImageFormat (
"png"
);
// Draw image
$image
-> drawImage (
$draw
);
header (
"Content-Type: image / png"
);
// Show image
echo
$image
-> getImageBlob();
?>
Output: Link : http://php.net/manual/en/imagickdraw.setstrokealpha.php