1--TEST--
2Test ImagickDraw, pushPattern
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 pushPattern($strokeColor, $fillColor, $backgroundColor) {
13    $draw = new \ImagickDraw();
14
15    $draw->setStrokeColor($strokeColor);
16    $draw->setFillColor($fillColor);
17    $draw->setStrokeWidth(1);
18    $draw->setStrokeOpacity(1);
19    $draw->setStrokeColor($strokeColor);
20    $draw->setFillColor($fillColor);
21
22    $draw->setStrokeWidth(1);
23
24    $draw->pushPattern("MyFirstPattern", 0, 0, 50, 50);
25    for ($x = 0; $x < 50; $x += 10) {
26        for ($y = 0; $y < 50; $y += 5) {
27            $positionX = $x + (($y / 5) % 5);
28            $draw->rectangle($positionX, $y, $positionX + 5, $y + 5);
29        }
30    }
31    $draw->popPattern();
32
33    $draw->setFillOpacity(0);
34    $draw->rectangle(100, 100, 400, 400);
35    $draw->setFillOpacity(1);
36
37    $draw->setFillOpacity(1);
38
39    $draw->push();
40    $draw->setFillPatternURL('#MyFirstPattern');
41    $draw->setFillColor('yellow');
42    $draw->rectangle(100, 100, 400, 400);
43    $draw->pop();
44
45    $imagick = new \Imagick();
46    $imagick->newImage(500, 500, $backgroundColor);
47    $imagick->setImageFormat("png");
48
49    $imagick->drawImage($draw);
50
51    $bytes = $imagick->getImageBlob();
52    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
53}
54
55pushPattern($strokeColor, $fillColor, $backgroundColor) ;
56echo "Ok";
57?>
58--EXPECTF--
59Ok