ImagickDraw::setStrokeOpacity()函数是PHP中的内置函数,用于指定笔触对象轮廓的不透明度。不透明度的值介于0到1之间。
用法:
bool ImagickDraw::setStrokeOpacity( $stroke_opacity )
参数:该函数接受单个参数$stroke_opacity,该参数用于将笔触不透明度的值保留为float类型。
返回值:该函数不返回任何值。
以下示例程序旨在说明PHP中的ImagickDraw::setStrokeOpacity()函数:
程序1:
<?php
// require_once('path/vendor/autoload.php');
// Create an ImagickDraw object to draw into.
$draw = new \ImagickDraw();
// Set the stroke color
$draw->setStrokeColor('Green');
// Set the filled color
$draw->setFillColor('Red');
// Set the stroke opacity
$draw->setStrokeOpacity(0.5);
// Set the stroke width
$draw->setStrokeWidth(9);
// Draw the rectangle
$draw->rectangle(40, 30, 200, 260);
// Create new imagick object
$image = new \Imagick();
// Create new image of given size
$image->newImage(240, 300, 'White');
// Set the image format
$image->setImageFormat("png");
// Draw the image
$image->drawImage($draw);
header("Content-Type: image/png");
// Display the output image
echo $image->getImageBlob();
?>
输出:
程序2:
<?php
// require_once('path/vendor/autoload.php');
// Create an ImagickDraw object to draw into.
$draw = new \ImagickDraw();
// Set the Stroke Color
$draw->setStrokeColor('Black');
// Set the Stroke Opacity
$draw->setStrokeOpacity(0.6);
// Set the Stroke Width
$draw->setStrokeWidth(4);
//Set the filled color
$draw->setFillColor('lightgreen');
$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 the polygon
$draw->polygon($points);
// Create new Imagick object
$image = new \Imagick();
// Set the 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();
?>
输出:
参考: http://php.net/manual/en/imagickdraw.setstrokeopacity.php
相关用法
- PHP GmagickDraw setstrokeopacity()用法及代码示例
- PHP ImagickDraw pop()用法及代码示例
- PHP ImagickDraw arc()用法及代码示例
- PHP ImagickDraw getFont()用法及代码示例
- PHP ImagickDraw setTextAntialias()用法及代码示例
- PHP ImagickDraw clone()用法及代码示例
- PHP ImagickDraw resetVectorGraphics()用法及代码示例
- PHP ImagickDraw setFillAlpha()用法及代码示例
- PHP ImagickDraw setFillOpacity()用法及代码示例
- PHP ImagickDraw getTextInterwordSpacing()用法及代码示例
- PHP ImagickDraw setTextInterlineSpacing()用法及代码示例
- PHP ImagickDraw getTextEncoding()用法及代码示例
- PHP ImagickDraw pathStart()用法及代码示例
- PHP ImagickDraw setTextEncoding()用法及代码示例
- PHP ImagickDraw comment()用法及代码示例
注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 PHP | ImagickDraw setStrokeOpacity() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。