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