1--TEST--
2imagefilledpolygon()
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7    if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available');
8?>
9--FILE--
10<?php
11
12echo "Simple test of imagefilledpolygon() function\n";
13
14$dest = dirname(realpath(__FILE__)) . '/imagefilledpolygon.png';
15
16$points = array(
17            40,  50,
18            20,  240,
19            60,  60,
20            240, 20,
21            50,  40,
22            10,  10
23            );
24
25// create a blank image
26$image = imagecreatetruecolor(250, 250);
27
28// set the background color to black
29$bg = imagecolorallocate($image, 0, 0, 0);
30
31// fill polygon with green
32$col_poly = imagecolorallocate($image, 0, 255, 0);
33
34// draw the polygon
35imagefilledpolygon($image, $points, $col_poly);
36
37// output the picture to a file
38imagepng($image, $dest);
39
40// get it back
41$image_in = imagecreatefrompng($dest);
42
43//check color of a point on edge..
44$col1 = imagecolorat($image_in, 40, 50);
45//.. a point in filled body
46$col2 = imagecolorat($image_in, 15, 15);
47// ..and a point on background
48$col3 = imagecolorat($image_in, 5, 5);
49
50$color1 = imagecolorsforindex($image_in, $col1);
51$color2 = imagecolorsforindex($image_in, $col2);
52$color3 = imagecolorsforindex($image_in, $col3);
53var_dump($color1, $color2, $color3);
54
55imagedestroy($image);
56imagedestroy($image_in);
57
58echo "Done\n";
59?>
60--CLEAN--
61<?php
62    $dest = dirname(realpath(__FILE__)) . '/imagefilledpolygon.png';
63    @unlink($dest);
64?>
65--EXPECT--
66Simple test of imagefilledpolygon() function
67array(4) {
68  ["red"]=>
69  int(0)
70  ["green"]=>
71  int(255)
72  ["blue"]=>
73  int(0)
74  ["alpha"]=>
75  int(0)
76}
77array(4) {
78  ["red"]=>
79  int(0)
80  ["green"]=>
81  int(255)
82  ["blue"]=>
83  int(0)
84  ["alpha"]=>
85  int(0)
86}
87array(4) {
88  ["red"]=>
89  int(0)
90  ["green"]=>
91  int(0)
92  ["blue"]=>
93  int(0)
94  ["alpha"]=>
95  int(0)
96}
97Done
98