ImagickDraw::setFillOpacity()函數是PHP中的內置函數,用於設置在使用填充顏色或填充紋理進行繪製時使用的不透明度。
用法:
bool ImagickDraw::setFillOpacity( $fillOpacity )
參數:該函數接受單個參數$fillOpacity,該參數用於將不透明度的值保存為float類型。
返回值:該函數不返回任何值。
以下示例程序旨在說明PHP中的ImagickDraw::setFillOpacity()函數:
程序1:
<?php
// require_once('vendor/autoload.php');
// Create ImagickDraw object
$draw = new \ImagickDraw();
// 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 Imagick object
$image = new \Imagick();
$image->newImage(500, 300, 'white');
// Set the image format
$image->setImageFormat("png");
// Render the draw commands in the
// ImagickDraw 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 ImagickDraw object
$draw = new \ImagickDraw();
// Set the stroke color
$strokeColor = new \ImagickPixel('Green');
// Set the filled color
$fillColor = new \ImagickPixel('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
$imagick = new \Imagick();
$imagick->newImage(300, 300, 'White');
// Set the image format
$imagick->setImageFormat("png");
// Render the draw commands in the
// ImagickDraw object into the image.
$imagick->drawImage($draw);
// Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>
輸出:
參考: http://php.net/manual/en/imagickdraw.setfillopacity.php
相關用法
- PHP GmagickDraw setfillopacity()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setFillAlpha()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
- PHP ImagickDraw pushPattern()用法及代碼示例
- PHP ImagickDraw popPattern()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw resetVectorGraphics()用法及代碼示例
- PHP ImagickDraw setTextKerning()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw pathStart()用法及代碼示例
- PHP ImagickDraw setClipUnits()用法及代碼示例
- PHP ImagickDraw polygon()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw setFillOpacity() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。