ImagickDraw::line()函數是PHP的Imagick庫中的內置函數,用於畫線。此函數使用當前筆觸顏色,筆觸不透明度和筆觸寬度繪製線條。
用法:
bool ImagickDraw::line( $sx, $sy, $ex, $ey )
參數:該函數接受上述和以下所述的四個參數:
- $sx:此參數采用起始x坐標的值。
- $sy:此參數采用起始y坐標的值。
- $ex:此參數采用x坐標的結束值。
- $ey:此參數采用y坐標結尾的值。
返回值:成功時此函數返回TRUE。
下麵在PHP中對ImagickDraw::line()函數進行編程:
程序:
<?php
// Create an Imagick object
$draw = new \ImagickDraw();
// Function to fill color
$draw->setFillColor('red');
// Function to draw line
$draw->line(10, 30, 180, 200);
// Create Imagick object
$imagick = new \Imagick();
// Create new image of given size
$imagick->newImage(300, 300, 'white');
// Set the image format
$imagick->setImageFormat("png");
// Function to draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
// Display the output image
echo $imagick->getImageBlob();
?>
輸出:
參考: http://php.net/manual/en/imagickdraw.line.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw getTextAntialias()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setFillColor()用法及代碼示例
- PHP ImagickDraw setFillRule()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw setGravity()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw getTextDecoration()用法及代碼示例
- PHP ImagickDraw getTextInterlineSpacing()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setFontSize()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw line() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。