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