summaryrefslogtreecommitdiff
path: root/ext/gd/tests/libgd00100.phpt
blob: abf4ee3339aa73d46330a5b69d3f9a361a8f2126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
--TEST--
libgd #100 (spurious horizontal line drawn by gdImageFilledPolygon)
--SKIPIF--
<?php
	if (!extension_loaded('gd')) die("skip gd extension not available\n");
	if (!GD_BUNDLED) die("skip requires bundled GD library\n");
?>
--FILE--
<?php
$im = imagecreatetruecolor(256, 256);

$white   = imagecolorallocatealpha($im, 255, 255, 255, 10);
$black   = imagecolorallocatealpha($im,   0,   0,   0, 10);
$red     = imagecolorallocatealpha($im, 255,   0,   0, 10);
$green   = imagecolorallocatealpha($im,   0, 255,   0, 10);
$blue    = imagecolorallocatealpha($im,   0,   0, 255, 10);
$yellow  = imagecolorallocatealpha($im, 255, 255,   0, 10);
$cyan    = imagecolorallocatealpha($im,   0, 255, 255, 10);
$magenta = imagecolorallocatealpha($im, 255,   0, 255, 10);
$purple  = imagecolorallocatealpha($im, 100,   0, 100, 10);

imagefilledrectangle($im, 0, 0, 255, 255, $white);

// M (bridge)
$top = 240;
$bot = 255;
$d = 30;
$x = 100;
$points = array(
  $x,      $top,
  $x+2*$d, $top,
  $x+2*$d, $bot,
  $x+$d,   ($top+$bot)/2,
  $x,      $bot
);
imagefilledpolygon($im, $points, 5, $yellow);

// left-facing M not on baseline
$top = 40;
$bot = 70;
$left = 120;
$right = 180;
$points = array(
  $left,  $top,
  $right, $top,
  $right, $bot,
  $left,  $bot,
  ($left+$right)/2, ($top+$bot)/2
);
imagefilledpolygon($im, $points, 5, $purple);

// left-facing M on baseline
$top = 240;
$bot = 270;
$left = 20;
$right = 80;
$points = array(
  $left,  $top,
  $right, $top,
  $right, $bot,
  $left,  $bot,
  ($left+$right)/2, ($top+$bot)/2
);
imagefilledpolygon($im, $points, 5, $magenta);

// left-facing M on ceiling
$top = -15;
$bot = 15;
$left = 20;
$right = 80;
$points = array(
  $left,  $top,
  $right, $top,
  $right, $bot,
  $left,  $bot,
  ($left+$right)/2, ($top+$bot)/2
);
imagefilledpolygon($im, $points, 5, $blue);

$d = 30;
$x = 150;
$y = 150;
$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
imagefilledpolygon($im, $diamond, 4, $green);

$x = 180;
$y = 225;
$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
imagefilledpolygon($im, $diamond, 4, $red);

$x = 225;
$y = 255;
$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
imagefilledpolygon($im, $diamond, 4, $cyan);

// M (bridge) not touching bottom boundary
$top = 100;
$bot = 150;
$x = 30;
$points = array(
  $x,      $top,
  $x+2*$d, $top,
  $x+2*$d, $bot,
  $x+$d,   ($top+$bot)/2,
  $x,      $bot
);
imagefilledpolygon($im, $points, 5, $black);

ob_start();
imagepng($im);
$png = ob_get_contents();
ob_end_clean();

echo md5($png);

imagedestroy($im);
?>
--EXPECTF--
2e6cf558bb4dadf60c8b608d5f8cda4e