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