ImagickDraw::setFillColor()函數是PHP中的內置函數,用於設置用於繪圖的填充顏色。
用法:
bool ImagickDraw::setFillColor( $fill_pixel )
參數:該函數接受單個參數
返回值:該函數不返回任何值。
以下示例程序旨在說明PHP中的ImagickDraw::setFillColor()函數:
程序1:
<?php
// require_once('path/vendor/autoload.php');
// Create an ImagickDraw object
$draw = new \ImagickDraw();
// Set stroke opacity
$draw->setStrokeOpacity(1);
// Set stroke color
$draw->setStrokeColor('Black');
// Set stroke opacity
$draw->setStrokeOpacity(0.8);
// Set stroke width
$draw->setStrokeWidth(10);
// Set Stroke Line Join
$draw->setStrokeLineJoin(Imagick::LINEJOIN_ROUND);
// Set Fill Color
$draw->setFillColor('lightgreen');
// Set Stroke Miter Limit
$draw->setStrokeMiterLimit(40 * 12);
$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 a polygon
$draw->polygon($points);
// Create a new imagick object
$image = new \Imagick();
// Set 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();
?>
輸出:
程序2:
<?php
// require_once('path/vendor/autoload.php');
// Create an ImagickDraw object
$draw = new \ImagickDraw();
// Set the stroke color
$draw->setStrokeColor('Green');
// Set Fill Color
$draw->setFillColor('Red');
// Set the stroke width
$draw->setStrokeWidth(7);
// Draw the rectangle
$draw->rectangle(40, 30, 200, 260);
// Create new Imagick object
$image = new \Imagick();
// Set the image dimension
$image->newImage(300, 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.setfillcolor.php
相關用法
- PHP GmagickDraw setfillcolor()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw getTextInterlineSpacing()用法及代碼示例
- PHP ImagickDraw affine()用法及代碼示例
- PHP ImagickDraw getTextDecoration()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw setTextInterwordSpacing()用法及代碼示例
- PHP ImagickDraw setStrokeOpacity()用法及代碼示例
- PHP ImagickDraw setGravity()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw getTextUnderColor()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw setFillColor() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。