GmagickDraw::setstrokeopacity()函數是PHP中的內置函數,用於指定筆觸對象輪廓的不透明度。不透明度的值介於0到1之間。
用法:
public GmagickDraw::setstrokeopacity( $stroke_opacity ) : GmagickDraw
參數:該函數接受單個參數$stroke_opacity,該參數用於將筆觸不透明度的值保留為浮點類型。
返回值:成功時,此函數返回GmagickDraw對象。
以下示例程序旨在說明PHP中的GmagickDraw::setstrokeopacity()函數:
程序1:
<?php
// require_once('path/vendor/autoload.php');
// Create an GmagickDraw object to draw into.
$draw = new \GmagickDraw();
// 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 gimagick 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();
?>
輸出:
程序2:
<?php
// require_once('path/vendor/autoload.php');
// Create an GmagickDraw object to draw into.
$draw = new \GmagickDraw();
// 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 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.net/manual/en/gmagickdraw.setstrokeopacity.php
相關用法
- PHP ImagickDraw setStrokeOpacity()用法及代碼示例
- PHP GmagickDraw arc()用法及代碼示例
- PHP GmagickDraw setstrokecolor()用法及代碼示例
- PHP GmagickDraw getfontweight()用法及代碼示例
- PHP GmagickDraw getstrokewidth()用法及代碼示例
- PHP GmagickDraw getstrokeopacity()用法及代碼示例
- PHP GmagickDraw roundrectangle()用法及代碼示例
- PHP GmagickDraw setfont()用法及代碼示例
- PHP GmagickDraw settextencoding()用法及代碼示例
- PHP GmagickDraw getfont()用法及代碼示例
- PHP GmagickDraw getfontsize()用法及代碼示例
- PHP GmagickDraw getfillopacity()用法及代碼示例
- PHP GmagickDraw getfontstyle()用法及代碼示例
- PHP GmagickDraw gettextdecoration()用法及代碼示例
- PHP GmagickDraw rectangle()用法及代碼示例
注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | GmagickDraw setstrokeopacity() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。