📜  PHP | imagickdraw setStrokeLineJoin()函数

📅  最后修改于: 2022-05-13 01:56:28.596000             🧑  作者: Mango

PHP | imagickdraw setStrokeLineJoin()函数

ImagickDraw::setStrokeLineJoin()函数是PHP中的一个内置函数,用于指定描边路径拐角处要使用的形状。

句法:

bool ImagickDraw::setStrokeLineJoin( $linejoin )

参数:此函数接受单个参数$linejoin ,该参数用于将线连接的值保存为整数类型。

LINEJOIN 常量:

  • imagick::LINEJOIN_UNDEFINED (整数)
  • imagick::LINEJOIN_MITER (整数)
  • imagick::LINEJOIN_ROUND (整数)
  • imagick::LINEJOIN_BEVEL (整数)

返回值:此函数不返回任何值。

下面的程序说明了PHP中的ImagickDraw::setStrokeLineJoin()函数:

方案一:

PHP
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 Parameters
$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();
?>


PHP
setStrokeWidth(1);
 
// Set the Stroke Color
$draw->setStrokeColor('black');
     
// Set the image filled color
$draw->setFillColor('yellow');
 
// Set the Stroke Width
$draw->setStrokeWidth(20);
 
// Declare 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();
?>


输出:

setstrokelinejoin

方案二:

PHP

setStrokeWidth(1);
 
// Set the Stroke Color
$draw->setStrokeColor('black');
     
// Set the image filled color
$draw->setFillColor('yellow');
 
// Set the Stroke Width
$draw->setStrokeWidth(20);
 
// Declare 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();
?>

输出:

setstrokelinejoin

参考: http: PHP。 PHP