PHP Conference Japan 2024

ImagickDraw::setFillRule

(PECL imagick 2, PECL imagick 3)

ImagickDraw::setFillRule設定繪製多邊形時使用的填充規則

說明

public ImagickDraw::setFillRule(int $fill_rule): bool
警告

此函式目前未有文件;僅提供其引數列表。

設定繪製多邊形時使用的填充規則。

參數

fill_rule

FILLRULE 常數之一 (imagick::FILLRULE_*)。

回傳值

不回傳值。

範例

範例 1 ImagickDraw::setFillRule() 範例

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

$draw = new \ImagickDraw();

$draw->setStrokeWidth(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);

$fillRules = [\Imagick::FILLRULE_NONZERO, \Imagick::FILLRULE_EVENODD];

$points = 11;
$size = 150;

$draw->translate(175, 160);

for (
$x = 0; $x < 2; $x++) {
$draw->setFillRule($fillRules[$x]);
$draw->pathStart();
for (
$n = 0; $n < $points * 2; $n++) {

if (
$n >= $points) {
$angle = fmod($n * 360 * 4 / $points, 360) * pi() / 180;
}
else {
$angle = fmod($n * 360 * 3 / $points, 360) * pi() / 180;
}

$positionX = $size * sin($angle);
$positionY = $size * cos($angle);

if (
$n == 0) {
$draw->pathMoveToAbsolute($positionX, $positionY);
}
else {
$draw->pathLineToAbsolute($positionX, $positionY);
}
}

$draw->pathClose();
$draw->pathFinish();

$draw->translate(325, 0);
}

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

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

?>

新增註解

使用者貢獻的註解

此頁面沒有使用者提供的註解。
To Top