GmagickDraw::setfillopacity()函數是PHP中的內置函數,用於設置工程圖圖像的不透明度。使用填充的顏色或填充的紋理繪製圖像時使用。
用法:
public GmagickDraw::setfillopacity( $fill_opacity ) : GmagickDraw
參數:該函數接受單個參數$fill_opacity,該參數用於將不透明度的值保留為float類型。
返回值:成功時,此函數返回GmagickDraw對象。
以下示例程序旨在說明PHP中的GmagickDraw::setfillopacity()函數:
程序1:
<?php
// require_once('vendor/autoload.php');
// Create GmagickDraw object
$draw = new \GmagickDraw ();
// Set the strike color
$draw->setStrokeColor('Green');
// Use setFillColor() Function
$draw->setFillColor('Red');
// Use setFillOpacity() Function
$draw->setFillOpacity(0.2);
$draw->setStrokeWidth(7);
// Create rectangle
$draw->rectangle(40, 30, 200, 260);
// Use setFillColor() Function
$draw->setFillColor('Red');
// Create rectangle of given size
$draw->rectangle(260, 30, 400, 260);
// Create an Gmagick object
$image = new \Gmagick ();
$image->newImage(500, 300, 'white');
// Set the image format
$image->setImageFormat("png");
// Render the draw commands in the
// GmagickDraw object into the image.
$image->drawImage($draw);
// Send the image to the browser
header("Content-Type: image/png");
echo $image->getImageBlob();
?>
輸出:
程序2:
<?php
// require_once('path/vendor/autoload.php');
// Create new GmagickDraw object
$draw = new \GmagickDraw ();
// Set the stroke color
$strokeColor = new \GmagickPixel('Green');
// Set the filled color
$fillColor = new \GmagickPixel('Red');
// Set the stroke color
$draw->setStrokeColor('Green');
// Set the filled color
$draw->setFillColor('Red');
// Use setFillOpacity() Function
$draw->setFillOpacity(0.5);
// Set the stroke width
$draw->setStrokeWidth(2);
$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 image object
$gmagick = new \Gmagick ();
$gmagick->newImage(300, 300, 'White');
// Set the image format
$gmagick->setImageFormat("png");
// Render the draw commands in the
// GmagickDraw object into the image.
$gmagick->drawImage($draw);
// Send the image to the browser
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>
輸出:
參考: http://php.net/manual/en/gmagickdraw.setfillopacity.php
相關用法
- PHP ImagickDraw setFillOpacity()用法及代碼示例
- PHP GmagickDraw arc()用法及代碼示例
- PHP GmagickDraw setfontsize()用法及代碼示例
- PHP GmagickDraw getfontsize()用法及代碼示例
- PHP GmagickDraw getstrokewidth()用法及代碼示例
- PHP GmagickDraw getstrokeopacity()用法及代碼示例
- PHP GmagickDraw getfontweight()用法及代碼示例
- PHP GmagickDraw setfont()用法及代碼示例
- PHP GmagickDraw settextencoding()用法及代碼示例
- PHP GmagickDraw getfont()用法及代碼示例
- PHP GmagickDraw gettextdecoration()用法及代碼示例
- PHP GmagickDraw rectangle()用法及代碼示例
- PHP GmagickDraw gettextencoding()用法及代碼示例
- PHP GmagickDraw rotate()用法及代碼示例
- PHP GmagickDraw getfontstyle()用法及代碼示例
注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | GmagickDraw setfillopacity() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。