📜  PHP | GmagickDraw setstrokeopacity()函数

📅  最后修改于: 2022-05-13 01:56:26.026000             🧑  作者: Mango

PHP | GmagickDraw setstrokeopacity()函数

GmagickDraw::setstrokeopacity()函数是PHP中的一个内置函数,用于指定描边对象轮廓的不透明度。不透明度的值介于 0 和 1 之间。

句法:

public GmagickDraw::setstrokeopacity( $stroke_opacity ) : GmagickDraw

参数:此函数接受单个参数$stroke_opacity ,该参数用于将描边不透明度的值保存为浮点类型。
返回值:此函数在成功时返回 GmagickDraw 对象。
下面的程序说明了PHP中的 GmagickDraw::setstrokeopacity()函数:
方案一:

php
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 gmagick object
$image = new \Gmagick();
 
// 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();
?>


php
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 Gmagick object
$image = new \Gmagick();
 
// 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();
?>


输出:

定线不透明度

方案二:

PHP

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 Gmagick object
$image = new \Gmagick();
 
// 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。 PHP