ImagickDraw::setStrokeAlpha()函数是PHP中的内置函数,用于指定笔触对象轮廓的不透明度。
用法:
bool ImagickDraw::setStrokeAlpha( $opacity )
参数:此函数接受单个参数不透明度,该参数用于指定笔触对象的透明度。它是浮点值,介于0和1之间。
返回值:此函数不返回任何值。
以下示例程序旨在说明PHP中的ImagickDraw::setStrokeAlpha()函数:
示例1:
<?php
// require_once('path/vendor/autoload.php');
// Create an Imagick Draw object
$draw = new \ImagickDraw();
// Set the stroke color
$strokeColor = new \ImagickPixel('Green');
// Set the fill color
$fillColor = new \ImagickPixel('Red');
// Set the stroke color
$draw->setStrokeColor('Green');
// Set the Fill Color
$draw->setFillColor('Red');
// Set the stroke width
$draw->setStrokeWidth(5);
// Set the stroke opacity
$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 an imagick object
$imagick = new \Imagick();
// Set the image dimensions
$imagick->newImage(300, 300, 'White');
// Set the image format
$imagick->setImageFormat("png");
// Draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
// Display the image
echo $imagick->getImageBlob();
?>
输出:
示例2:
<?php
// require_once('path/vendor/autoload.php');
// Create an ImagickDraw object
$draw = new \ImagickDraw();
// Set the Stroke Color
$draw->setStrokeColor('Green');
// Set the Fill Color
$draw->setFillColor('Red');
// Set the stroke width
$draw->setStrokeWidth(7);
// Set the stroke opacity
$draw->setStrokeOpacity(0.5);
// Draw the rectangle
$draw->rectangle(40, 30, 200, 260);
// Create an Imagick object
$image = new \Imagick();
// Set the image dimensions
$image->newImage(250, 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.setstrokealpha.php
相关用法
- PHP ImagickDraw pop()用法及代码示例
- PHP ImagickDraw arc()用法及代码示例
- PHP ImagickDraw getStrokeDashOffset()用法及代码示例
- PHP ImagickDraw getTextAlignment()用法及代码示例
- PHP ImagickDraw destroy()用法及代码示例
- PHP ImagickDraw getTextEncoding()用法及代码示例
- PHP ImagickDraw getFillRule()用法及代码示例
- PHP ImagickDraw setTextEncoding()用法及代码示例
- PHP ImagickDraw getClipPath()用法及代码示例
- PHP ImagickDraw color()用法及代码示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代码示例
- PHP ImagickDraw comment()用法及代码示例
- PHP ImagickDraw polyline()用法及代码示例
- PHP ImagickDraw setClipPath()用法及代码示例
- PHP ImagickDraw pathMoveToRelative()用法及代码示例
注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 PHP | ImagickDraw setStrokeAlpha() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。