1--TEST--
2Test ImagickPixel, construct
3--SKIPIF--
4<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8
9function construct() {
10
11    $columns = 4;
12
13    $exampleColors = array(
14        "rgba(100%, 0%, 0%, 0.5)",
15        "hsb(33.3333%, 100%,  75%)", // medium green
16        "hsl(120, 255,   191.25)", //medium green
17        "graya(50%, 0.5)", //  semi-transparent mid gray
18        "LightCoral", "none", //"cmyk(0.9, 0.48, 0.83, 0.50)",
19        "#f00", //  #rgb
20        "#ff0000", //  #rrggbb
21        "#ff0000ff", //  #rrggbbaa
22        "#ffff00000000", //  #rrrrggggbbbb
23        "#ffff00000000ffff", //  #rrrrggggbbbbaaaa
24        "rgb(255, 0, 0)", //  an integer in the range 0—255 for each component
25        "rgb(100.0%, 0.0%, 0.0%)", //  a float in the range 0—100% for each component
26        "rgb(255, 0, 0)", //  range 0 - 255
27        "rgba(255, 0, 0, 1.0)", //  the same, with an explicit alpha value
28        "rgb(100%, 0%, 0%)", //  range 0.0% - 100.0%
29        "rgba(100%, 0%, 0%, 1.0)", //  the same, with an explicit alpha value
30    );
31
32    $draw = new \ImagickDraw();
33    $count = 0;
34    $black = new \ImagickPixel('rgb(0, 0, 0)');
35
36    foreach ($exampleColors as $exampleColor) {
37        $color = new \ImagickPixel($exampleColor);
38
39        $draw->setstrokewidth(1.0);
40        $draw->setStrokeColor($black);
41        $draw->setFillColor($color);
42        $offsetX = ($count % $columns) * 50 + 5;
43        $offsetY = intval($count / $columns) * 50 + 5;
44        $draw->rectangle(0 + $offsetX, 0 + $offsetY, 40 + $offsetX, 40 + $offsetY);
45        $count++;
46    }
47
48    $image = new \Imagick();
49    $image->newImage(350, 350, "blue");
50    $image->setImageFormat("png");
51    $image->drawImage($draw);
52    $bytes = $image->getImageBlob();
53    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
54}
55
56construct() ;
57echo "Ok";
58?>
59--EXPECTF--
60Ok