PHP Conference Japan 2024

ImagickDraw::polygon

(PECL imagick 2, PECL imagick 3)

ImagickDraw::polygon繪製多邊形

說明

public ImagickDraw::polygon(array $coordinates): bool
警告

此函式目前沒有文件;只有其引數列表可用。

使用目前筆觸、筆觸寬度以及填滿顏色或紋理,使用指定的座標陣列繪製多邊形。

參數

coordinates

多維陣列,例如 array( array( 'x' => 3, 'y' => 4 ), array( 'x' => 2, 'y' => 6 ) );

回傳值

成功時回傳 true

範例

範例 #1 ImagickDraw::polygon() 範例

<?php
function polygon($strokeColor, $fillColor, $backgroundColor) {

$draw = new \ImagickDraw();

$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setStrokeWidth(4);

$draw->setFillColor($fillColor);

$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],
];

$draw->polygon($points);

$image = new \Imagick();
$image->newImage(500, 300, $backgroundColor);
$image->setImageFormat("png");
$image->drawImage($draw);

header("Content-Type: image/png");
echo
$image->getImageBlob();
}

?>

新增註解

使用者貢獻的註解

此頁面沒有使用者貢獻的註解。
To Top