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