xref: /PHP-5.6/ext/gd/tests/libgd00100.phpt (revision dc09f309)
1--TEST--
2libgd #100 (spurious horizontal line drawn by gdImageFilledPolygon)
3--SKIPIF--
4<?php
5	if (!extension_loaded('gd')) die("skip gd extension not available\n");
6	if (!GD_BUNDLED) die("skip requires bundled GD library\n");
7?>
8--FILE--
9<?php
10$im = imagecreatetruecolor(256, 256);
11
12$white   = imagecolorallocatealpha($im, 255, 255, 255, 10);
13$black   = imagecolorallocatealpha($im,   0,   0,   0, 10);
14$red     = imagecolorallocatealpha($im, 255,   0,   0, 10);
15$green   = imagecolorallocatealpha($im,   0, 255,   0, 10);
16$blue    = imagecolorallocatealpha($im,   0,   0, 255, 10);
17$yellow  = imagecolorallocatealpha($im, 255, 255,   0, 10);
18$cyan    = imagecolorallocatealpha($im,   0, 255, 255, 10);
19$magenta = imagecolorallocatealpha($im, 255,   0, 255, 10);
20$purple  = imagecolorallocatealpha($im, 100,   0, 100, 10);
21
22imagefilledrectangle($im, 0, 0, 255, 255, $white);
23
24// M (bridge)
25$top = 240;
26$bot = 255;
27$d = 30;
28$x = 100;
29$points = array(
30  $x,      $top,
31  $x+2*$d, $top,
32  $x+2*$d, $bot,
33  $x+$d,   ($top+$bot)/2,
34  $x,      $bot
35);
36imagefilledpolygon($im, $points, 5, $yellow);
37
38// left-facing M not on baseline
39$top = 40;
40$bot = 70;
41$left = 120;
42$right = 180;
43$points = array(
44  $left,  $top,
45  $right, $top,
46  $right, $bot,
47  $left,  $bot,
48  ($left+$right)/2, ($top+$bot)/2
49);
50imagefilledpolygon($im, $points, 5, $purple);
51
52// left-facing M on baseline
53$top = 240;
54$bot = 270;
55$left = 20;
56$right = 80;
57$points = array(
58  $left,  $top,
59  $right, $top,
60  $right, $bot,
61  $left,  $bot,
62  ($left+$right)/2, ($top+$bot)/2
63);
64imagefilledpolygon($im, $points, 5, $magenta);
65
66// left-facing M on ceiling
67$top = -15;
68$bot = 15;
69$left = 20;
70$right = 80;
71$points = array(
72  $left,  $top,
73  $right, $top,
74  $right, $bot,
75  $left,  $bot,
76  ($left+$right)/2, ($top+$bot)/2
77);
78imagefilledpolygon($im, $points, 5, $blue);
79
80$d = 30;
81$x = 150;
82$y = 150;
83$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
84imagefilledpolygon($im, $diamond, 4, $green);
85
86$x = 180;
87$y = 225;
88$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
89imagefilledpolygon($im, $diamond, 4, $red);
90
91$x = 225;
92$y = 255;
93$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
94imagefilledpolygon($im, $diamond, 4, $cyan);
95
96// M (bridge) not touching bottom boundary
97$top = 100;
98$bot = 150;
99$x = 30;
100$points = array(
101  $x,      $top,
102  $x+2*$d, $top,
103  $x+2*$d, $bot,
104  $x+$d,   ($top+$bot)/2,
105  $x,      $bot
106);
107imagefilledpolygon($im, $points, 5, $black);
108
109include_once __DIR__ . '/func.inc';
110test_image_equals_file(__DIR__ . '/libgd00100.png', $im);
111
112imagedestroy($im);
113?>
114--EXPECTF--
115The images are equal.
116