ImagickDraw::polyline()函数是PHP的Imagick库中的内置函数,该函数用于使用指定的坐标数组使用当前笔触,笔触宽度以及填充颜色或纹理绘制折线。
用法:
bool ImagickDraw::polyline( $coordinates )
参数:该函数接受单个参数$coordinates,该参数用于将点的坐标保存为数组。
返回值:成功时此函数返回True。
以下示例程序旨在说明PHP中的ImagickDraw::polyline()函数:
程序1:
<?php
// Create an ImagickDraw Object
$draw = new ImagickDraw();
// Set Stroke Opacity
$draw->setStrokeOpacity(1);
// Set Stroke Color
$draw->setStrokeColor('green');
// Set Fill Color
$draw->setFillColor('red');
// Set Stroke Width
$draw->setStrokeWidth(5);
// Define the points at which lines to be draw
$points = [
['x' => 40 * 5, 'y' => 10 * 5],
['x' => 20 * 5, 'y' => 20 * 5],
['x' => 70 * 5, 'y' => 50 * 5],
['x' => 60 * 5, 'y' => 15 * 5]
];
// Call Polyline Function
$draw->polyline($points);
// Create an Imagick Object
$image = new Imagick();
// Create new Image
$image->newImage(500, 300, 'white');
// Set Image Format
$image->setImageFormat("png");
// Draw Image
$image->drawImage($draw);
header("Content-Type: image/png");
// Display the output image
echo $image->getImageBlob();
?>
输出:
程序2:
<?php
// Create an ImagickDraw Object
$draw = new ImagickDraw();
// Set Stroke Opacity
$draw->setStrokeOpacity(1);
// Set Stroke Color
$draw->setStrokeColor('Black');
// Set Fill Color
$draw->setFillColor('Green');
// Set Stroke Width
$draw->setStrokeWidth(3);
// Define the points at which lines to be draw
$points = [
['x' => 40 * 5, 'y' => 10 * 5],
['x' => 20 * 5, 'y' => 20 * 5],
['x' => 70 * 5, 'y' => 50 * 5],
['x' => 40 * 5, 'y' => 10 * 5]
];
// Set the Font Size
$draw->setFontSize(50);
// Set the font family
$draw->setFontFamily('Ubuntu-Mono');
// Set the text to be added
$draw->annotation(30, 40, "GeeksForGeeks");
// Call Polyline Function
$draw->polyline($points);
// Create an Imagick Object
$image = new Imagick();
// Create new Image
$image->newImage(500, 300, 'white');
// Set Image Format
$image->setImageFormat("png");
// Draw Image
$image->drawImage($draw);
header("Content-Type: image/png");
// Display the output image
echo $image->getImageBlob();
?>
输出:
参考: http://php.net/manual/en/imagickdraw.polyline.php
相关用法
- PHP GmagickDraw polyline()用法及代码示例
- PHP ImagickDraw pop()用法及代码示例
- PHP ImagickDraw arc()用法及代码示例
- PHP ImagickDraw popPattern()用法及代码示例
- PHP ImagickDraw setFillOpacity()用法及代码示例
- PHP ImagickDraw setTextKerning()用法及代码示例
- PHP ImagickDraw setFillAlpha()用法及代码示例
- PHP ImagickDraw resetVectorGraphics()用法及代码示例
- PHP ImagickDraw roundRectangle()用法及代码示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代码示例
- PHP ImagickDraw pushPattern()用法及代码示例
- PHP ImagickDraw setTextAntialias()用法及代码示例
- PHP ImagickDraw ellipse()用法及代码示例
- PHP ImagickDraw pathStart()用法及代码示例
- PHP ImagickDraw setTextDecoration()用法及代码示例
注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 PHP | ImagickDraw polyline() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。