69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
--TEST--
|
|
Test ImagickDraw, setFillRule
|
|
--SKIPIF--
|
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
$backgroundColor = 'rgb(225, 225, 225)';
|
|
$strokeColor = 'rgb(0, 0, 0)';
|
|
$fillColor = 'DodgerBlue2';
|
|
|
|
function setFillRule($fillColor, $strokeColor, $backgroundColor) {
|
|
|
|
$draw = new \ImagickDraw();
|
|
|
|
$draw->setStrokeWidth(1);
|
|
$draw->setStrokeColor($strokeColor);
|
|
$draw->setFillColor($fillColor);
|
|
|
|
$fillRules = array(\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);
|
|
|
|
$bytes = $image->getImageBlob();
|
|
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
|
|
}
|
|
|
|
setFillRule($fillColor, $strokeColor, $backgroundColor) ;
|
|
echo "Ok";
|
|
?>
|
|
--EXPECTF--
|
|
Ok
|