Annotation of embedaddon/php/ext/gd/tests/lines.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: imageline no AA
        !             3: --SKIPIF--
        !             4: <?php
        !             5:         if (!function_exists('imageline')) die("skip gd extension not available\n");
        !             6: ?>
        !             7: --FILE--
        !             8: <?php
        !             9: $im = imagecreatetruecolor(6,6);
        !            10: imagefill($im, 0,0, 0xffffff);
        !            11: 
        !            12: // Wrong argument count
        !            13: imageline($im, 0,0, 5,5);
        !            14: 
        !            15: 
        !            16: // Horizontal line
        !            17: imageline($im, 0,5, 5,5, 0x00ff00);
        !            18: 
        !            19: $p1 = imagecolorat($im, 0,5)==0x00ff00;
        !            20: $p2 = imagecolorat($im, 5,5)==0x00ff00;
        !            21: $p3 = true;
        !            22: for ($x=1; $x<5; $x++) {
        !            23:        $p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00);
        !            24: }
        !            25: if ($p1 && $p2 && $p3) {
        !            26:        echo "Horizontal: ok\n";
        !            27: }
        !            28: 
        !            29: $im = imagecreatetruecolor(6,6);
        !            30: imagefill($im, 0,0, 0xffffff);
        !            31: 
        !            32: imageline($im, 0,0, 0,5, 0x00ff00);
        !            33: $p1 = imagecolorat($im, 0,0)==0x00ff00;
        !            34: $p2 = imagecolorat($im, 0,5)==0x00ff00;
        !            35: $p3 = true;
        !            36: for ($y=1; $y<5; $y++) {
        !            37:        $p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00);
        !            38: }
        !            39: 
        !            40: if ($p1 && $p2 && $p3) {
        !            41:        echo "Vertical: ok\n";
        !            42: }
        !            43: 
        !            44: 
        !            45: $im = imagecreatetruecolor(6,6);
        !            46: imagefill($im, 0,0, 0xffffff);
        !            47: imageline($im, 0,0, 5,5, 0x00ff00);
        !            48: 
        !            49: 
        !            50: // Diagonal
        !            51: $p1 = imagecolorat($im, 0,0)==0x00ff00;
        !            52: $p2 = imagecolorat($im, 5,5)==0x00ff00;
        !            53: $x=1;
        !            54: $p3 = true;
        !            55: 
        !            56: for ($y=1; $y<5; $y++) {
        !            57:        $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00);
        !            58:        $x++;
        !            59: }
        !            60: 
        !            61: if ($p1 && $p2 && $p3) {
        !            62:        echo "Diagonal: ok\n";
        !            63: }
        !            64: 
        !            65: // Outside
        !            66: $im = imagecreatetruecolor(6,6);
        !            67: imagefill($im, 0,0, 0xffffff);
        !            68: imageline($im, 12, 12, 23,23, 0x00ff00);
        !            69: $p3 = true;
        !            70: for ($x=0; $x<6; $x++) {
        !            71:        for ($y=0; $y<6; $y++) {
        !            72:                $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00);
        !            73:        }
        !            74: }
        !            75: if ($p3) {
        !            76:        echo "Outside 1: ok\n";
        !            77: }
        !            78: 
        !            79: $im = imagecreatetruecolor(6,6);
        !            80: imagefill($im, 0,0, 0xffffff);
        !            81: imageline($im, -12, -12, -23,-23, 0x00ff00);
        !            82: $p3 = true;
        !            83: for ($x=0; $x<6; $x++) {
        !            84:        for ($y=0; $y<6; $y++) {
        !            85:                $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00);
        !            86:        }
        !            87: }
        !            88: if ($p3) {
        !            89:        echo "Outside 2: ok\n";
        !            90: }
        !            91: 
        !            92: $im = imagecreatetruecolor(6,6);
        !            93: imagefill($im, 0,0, 0xffffff);
        !            94: imageline($im, -1, -1, 4,4, 0x00ff00);
        !            95: $p3 = true;
        !            96: for ($x=0; $x<5; $x++) {
        !            97:        for ($y=0; $y<5; $y++) {
        !            98:                $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00);
        !            99:        }
        !           100: }
        !           101: if ($p3) {
        !           102:        echo "Outside 2: ok\n";
        !           103: }
        !           104: 
        !           105: 
        !           106: ?>
        !           107: --EXPECTF--
        !           108: 
        !           109: Warning: imageline() expects exactly 6 parameters, 5 given in %s on line %d
        !           110: Horizontal: ok
        !           111: Vertical: ok
        !           112: Diagonal: ok
        !           113: Outside 1: ok
        !           114: Outside 2: ok

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