1--TEST--
2Test ImagickDraw, setClipRule
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 setClipRule($strokeColor, $fillColor, $backgroundColor) {
13
14    $draw = new \ImagickDraw();
15
16    $draw->setStrokeColor($strokeColor);
17    $draw->setFillColor($fillColor);
18    $draw->setStrokeOpacity(1);
19    $draw->setStrokeWidth(2);
20    //\Imagick::FILLRULE_EVENODD
21    //\Imagick::FILLRULE_NONZERO
22
23    $clipPathName = 'testClipPath';
24    $draw->pushClipPath($clipPathName);
25    $draw->setClipRule(\Imagick::FILLRULE_EVENODD);
26
27    $draw->rectangle(0, 0, 300, 500);
28    $draw->rectangle(200, 0, 500, 500);
29    $draw->popClipPath();
30    $draw->setClipPath($clipPathName);
31    $draw->rectangle(200, 200, 300, 300);
32
33    $clipRule = $draw->getClipRule();
34    if ($clipRule != \Imagick::FILLRULE_EVENODD) {
35        echo "Failed to get correct clipRule $clipRule != \Imagick::FILLRULE_EVENODD \n";
36    }
37
38    $imagick = new \Imagick();
39    $imagick->newImage(500, 500, $backgroundColor);
40    $imagick->setImageFormat("png");
41
42    $imagick->drawImage($draw);
43
44    $bytes = $imagick->getImageBlob();
45    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
46}
47
48setClipRule($strokeColor, $fillColor, $backgroundColor) ;
49echo "Ok";
50?>
51--EXPECTF--
52Ok