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