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