1--TEST--
2imagepolygon()
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7    if (!function_exists('imagepolygon')) die('skip imagepolygon() not available');
8    if (!(imagetypes() & IMG_PNG)) {
9        die("skip No PNG support");
10    }
11?>
12--FILE--
13<?php
14
15echo "Simple test of imagepolygon() function\n";
16
17$dest = dirname(realpath(__FILE__)) . '/imagepolygon.png';
18
19// create a blank image
20$image = imagecreatetruecolor(400, 300);
21
22// set the background color to black
23$bg = imagecolorallocate($image, 0, 0, 0);
24
25// draw a red polygon
26$col_poly = imagecolorallocate($image, 255, 0, 0);
27
28// draw the polygon
29imagepolygon($image, array (
30        0,   0,
31        100, 200,
32        300, 200
33    ),
34    $col_poly);
35
36// output the picture to a file
37imagepng($image, $dest);
38
39$col1 = imagecolorat($image, 100, 200);
40$col2 = imagecolorat($image, 100, 100);
41$color1 = imagecolorsforindex($image, $col1);
42$color2 = imagecolorsforindex($image, $col2);
43var_dump($color1, $color2);
44
45imagedestroy($image);
46
47echo "Done\n";
48?>
49--CLEAN--
50<?php
51    $dest = dirname(realpath(__FILE__)) . '/imagepolygon.png';
52    @unlink($dest);
53?>
54--EXPECT--
55Simple test of imagepolygon() function
56array(4) {
57  ["red"]=>
58  int(255)
59  ["green"]=>
60  int(0)
61  ["blue"]=>
62  int(0)
63  ["alpha"]=>
64  int(0)
65}
66array(4) {
67  ["red"]=>
68  int(0)
69  ["green"]=>
70  int(0)
71  ["blue"]=>
72  int(0)
73  ["alpha"]=>
74  int(0)
75}
76Done
77