ImagickDraw::pathCurveToSmoothRelative()函數是PHP中的一個內置函數,用於使用相對坐標從當前點到(x,y)繪製三次貝塞爾曲線。
用法:
bool ImagickDraw::pathCurveToSmoothRelative( float $x2, float $y2, float $x, float $y )
參數:該函數接受上述和以下所述的四個參數:
- $x2:它指定第二個控製點的x坐標。
- $y2:它指定第二個控製點的y坐標。
- $x:它指定終點的x坐標。
- $y:它指定終點的y坐標。
返回值:成功時此函數返回TRUE。
異常:該函數在錯誤時引發ImagickException。
下麵給出的程序說明了PHP中的ImagickDraw::pathCurveToSmoothRelative()函數:
程序1:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'skyblue');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the fill color
$draw->setFillColor('skyblue');
// Set the stroke color
$draw->setStrokeColor('black');
// Set the stroke width
$draw->setStrokeWidth(5);
// Draw a painting
$draw->pathStart();
$draw->pathMoveToRelative(335, 70);
$draw->pathCurveToSmoothRelative(50, -50, 60, 20);
$draw->pathCurveToSmoothRelative(50, -50, 60, 20);
$draw->pathMoveToRelative(50, 50);
$draw->pathCurveToSmoothRelative(50, -50, 60, 20);
$draw->pathCurveToSmoothRelative(50, -50, 60, 20);
$draw->pathMoveToRelative(-500, 0);
$draw->pathCurveToSmoothRelative(50, -50, 60, 20);
$draw->pathCurveToSmoothRelative(50, -50, 60, 20);
$draw->pathFinish();
// Set the fill color
$draw->setFillColor('yellow');
// Draw a circle
$draw->circle(20, 20, 100, 20);
// Set the stroke width
$draw->setStrokeWidth(1);
// Set the fond size
$draw->setFontSize(40);
// Set the fill color
$draw->setFillColor('yellow');
// Annotate the text
$draw->annotation(500, 40, 'Summer Vibes');
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type:image/png");
echo $imagick->getImageBlob();
?>
輸出:
程序2:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'cyan');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
$draw->setFillColor('purple');
// Set the stroke color
$draw->setStrokeColor('blue');
// Set the stroke width
$draw->setStrokeWidth(15);
// Draw curves to Quadratic Bezier Relative (with pathClose())
$draw->pathStart();
$draw->pathCurveToSmoothRelative(-200, 250, 1900, 1250);
$draw->pathClose();
$draw->pathFinish();
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type:image/png");
echo $imagick->getImageBlob();
?>
輸出:
參考: https://www.php.net/manual/en/imagickdraw.pathcurvetosmoothrelative.php
相關用法
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw pathStart()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothAbsolute()用法及代碼示例
- PHP ImagickDraw setFontSize()用法及代碼示例
- PHP ImagickDraw setFillOpacity()用法及代碼示例
- PHP ImagickDraw setTextDecoration()用法及代碼示例
- PHP ImagickDraw setTextUnderColor()用法及代碼示例
- PHP ImagickDraw polygon()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw pathCurveToSmoothRelative() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。