Annotation of embedaddon/php/ext/gd/tests/imagepolygon_basic.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>