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