ImagickDraw::setStrokeLineJoin()函數是PHP中的內置函數,用於指定筆觸路徑時在拐角處使用的形狀。
用法:
bool ImagickDraw::setStrokeLineJoin( $linejoin )
參數:該函數接受單個參數$linejoin,該參數用於將線連接的值保存為整數類型。
LINEJOIN constants:
- imagick::LINEJOIN_UNDEFINED(整數)
- imagick::LINEJOIN_MITER(整數)
- imagick::LINEJOIN_ROUND(整數)
- imagick::LINEJOIN_BEVEL(整數)
返回值:該函數不返回任何值。
以下示例程序旨在說明PHP中的ImagickDraw::setStrokeLineJoin()函數:
程序1:
<?php
// require_once('path/vendor/autoload.php');
// Create an ImagickDraw object to draw into.
$draw = new \ImagickDraw();
// Set the stroke opacity
$draw->setStrokeOpacity(1);
// Set the stroke color
$draw->setStrokeColor('Black');
// Set the stroke opacity
$draw->setStrokeOpacity(0.8);
//Set the stroke width
$draw->setStrokeWidth(10);
// Set Stroke Line Join Parameteres
$draw->setStrokeLineJoin(Imagick::LINEJOIN_ROUND);
// Set the image filled color
$draw->setFillColor('lightgreen');
// Set the 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 the polygon
$draw->polygon($points);
// Create new Imagick object
$image = new \Imagick();
// Set the dimension of image
$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
// Create an ImagickDraw object
$draw = new ImagickDraw();
// Set the Stroke Width
$draw->setStrokeWidth(1);
// Set the Stroke Color
$draw->setStrokeColor('black');
// Set the image filled color
$draw->setFillColor('yellow');
// Set the Stroke Width
$draw->setStrokeWidth(20);
// Decalare the offset variable
$offset = 220;
$lineJoinStyle = [
\Imagick::LINEJOIN_MITER,
\Imagick::LINEJOIN_ROUND,
\Imagick::LINEJOIN_BEVEL,
];
for ($x = 0; $x < count($lineJoinStyle); $x++) {
$draw->setStrokeLineJoin($lineJoinStyle[$x]);
$points = [
['x' => 40 * 5, 'y' => 10 * 5 + $x * $offset],
['x' => 20 * 5, 'y' => 20 * 5 + $x * $offset],
['x' => 70 * 5, 'y' => 50 * 5 + $x * $offset],
['x' => 40 * 5, 'y' => 10 * 5 + $x * $offset],
];
// Draw the polygon
$draw->polyline($points);
}
// Create new Imagick object
$image = new \Imagick();
// Set the image dimensions
$image->newImage(500, 700, '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.setstrokelinejoin.php
相關用法
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw clone()用法及代碼示例
- PHP ImagickDraw setFillAlpha()用法及代碼示例
- PHP ImagickDraw resetVectorGraphics()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierRelative()用法及代碼示例
- PHP ImagickDraw setTextInterlineSpacing()用法及代碼示例
- PHP ImagickDraw getFont()用法及代碼示例
- PHP ImagickDraw getTextInterwordSpacing()用法及代碼示例
- PHP ImagickDraw setFillOpacity()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw getFontWeight()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw setStrokeLineJoin() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。