PHP | imagickdraw pathCurveToQuadraticBezierSmoothAbsolute()函数
ImagickDraw::pathCurveToQuadraticBezierSmoothAbsolute()函数是PHP中的一个内置函数,用于绘制作为参数曲线的二次贝塞尔曲线。此函数可以平滑地从二次曲线延续曲线。
句法:
bool ImagickDraw::pathCurveToQuadraticBezierSmoothAbsolute( float $x, float $y )
参数:该函数接受上面提到的两个参数,如下所述:
- $x:指定结束的 x 坐标
- $y:它指定结束 y 坐标
返回值:此函数在成功时返回 TRUE。
异常:此函数在出错时抛出 ImagickException。
下面给出的程序说明了PHP中的ImagickDraw::pathCurveToQuadraticBezierSmoothAbsolute()函数:
方案一:
newImage(800, 250, 'black');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
$draw->setFillColor('black');
// Set the stroke color
$draw->setStrokeColor('red');
// Draw curves to Quadratic Bezier Smooth Absolute (without pathClose())
$draw->pathStart();
$draw->pathCurveToQuadraticBezierSmoothAbsolute(3950, 250);
$draw->pathCurveToQuadraticBezierSmoothAbsolute(2950, 250);
$draw->pathCurveToQuadraticBezierSmoothAbsolute(390, 250);
$draw->pathFinish();
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>
输出:
方案二:
newImage(800, 250, 'black');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
$draw->setFillColor('black');
// Set the stroke color
$draw->setStrokeColor('yellow');
// Draw curves to Quadratic Bezier Smooth Absolute (with pathClose())
$draw->pathStart();
$draw->pathCurveToQuadraticBezierSmoothAbsolute(3950, 250);
$draw->pathCurveToQuadraticBezierSmoothAbsolute(950, 250);
$draw->pathCurveToQuadraticBezierSmoothAbsolute(2390, 250);
$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.pathcurvetoquadraticbeziersmoothabsolute。 PHP