1--TEST--
2Test ImagickDraw, setFillRule
3--SKIPIF--
4<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8$backgroundColor = 'rgb(225, 225, 225)';
9$strokeColor = 'rgb(0, 0, 0)';
10$fillColor = 'DodgerBlue2';
11
12function setFillRule($fillColor, $strokeColor, $backgroundColor) {
13
14    $draw = new \ImagickDraw();
15
16    $draw->setStrokeWidth(1);
17    $draw->setStrokeColor($strokeColor);
18    $draw->setFillColor($fillColor);
19
20    $fillRules = array(\Imagick::FILLRULE_NONZERO, \Imagick::FILLRULE_EVENODD);
21
22    $points = 11;
23    $size = 150;
24
25    $draw->translate(175, 160);
26
27    for ($x = 0; $x < 2; $x++) {
28        $draw->setFillRule($fillRules[$x]);
29        $draw->pathStart();
30        for ($n = 0; $n < $points * 2; $n++) {
31
32            if ($n >= $points) {
33                $angle = fmod($n * 360 * 4 / $points, 360) * pi() / 180;
34            }
35            else {
36                $angle = fmod($n * 360 * 3 / $points, 360) * pi() / 180;
37            }
38
39            $positionX = $size * sin($angle);
40            $positionY = $size * cos($angle);
41
42            if ($n == 0) {
43                $draw->pathMoveToAbsolute($positionX, $positionY);
44            }
45            else {
46                $draw->pathLineToAbsolute($positionX, $positionY);
47            }
48        }
49
50        $draw->pathClose();
51        $draw->pathFinish();
52
53        $draw->translate(325, 0);
54    }
55
56    $image = new \Imagick();
57    $image->newImage(700, 320, $backgroundColor);
58    $image->setImageFormat("png");
59    $image->drawImage($draw);
60
61    $bytes = $image->getImageBlob();
62    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
63}
64
65setFillRule($fillColor, $strokeColor, $backgroundColor) ;
66echo "Ok";
67?>
68--EXPECTF--
69Ok