5
if (!function_exists('imageline')) die("skip gd extension not available\n");
9
$im = imagecreatetruecolor(6,6);
10
imagefill($im, 0,0, 0xffffff);
12
// Wrong argument count
13
imageline($im, 0,0, 5,5);
17
imageline($im, 0,5, 5,5, 0x00ff00);
19
$p1 = imagecolorat($im, 0,5)==0x00ff00;
20
$p2 = imagecolorat($im, 5,5)==0x00ff00;
22
for ($x=1; $x<5; $x++) {
23
$p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00);
25
if ($p1 && $p2 && $p3) {
26
echo "Horizontal: ok\n";
29
$im = imagecreatetruecolor(6,6);
30
imagefill($im, 0,0, 0xffffff);
32
imageline($im, 0,0, 0,5, 0x00ff00);
33
$p1 = imagecolorat($im, 0,0)==0x00ff00;
34
$p2 = imagecolorat($im, 0,5)==0x00ff00;
36
for ($y=1; $y<5; $y++) {
37
$p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00);
40
if ($p1 && $p2 && $p3) {
41
echo "Vertical: ok\n";
45
$im = imagecreatetruecolor(6,6);
46
imagefill($im, 0,0, 0xffffff);
47
imageline($im, 0,0, 5,5, 0x00ff00);
51
$p1 = imagecolorat($im, 0,0)==0x00ff00;
52
$p2 = imagecolorat($im, 5,5)==0x00ff00;
56
for ($y=1; $y<5; $y++) {
57
$p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00);
61
if ($p1 && $p2 && $p3) {
62
echo "Diagonal: ok\n";
66
$im = imagecreatetruecolor(6,6);
67
imagefill($im, 0,0, 0xffffff);
68
imageline($im, 12, 12, 23,23, 0x00ff00);
70
for ($x=0; $x<6; $x++) {
71
for ($y=0; $y<6; $y++) {
72
$p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00);
76
echo "Outside 1: ok\n";
79
$im = imagecreatetruecolor(6,6);
80
imagefill($im, 0,0, 0xffffff);
81
imageline($im, -12, -12, -23,-23, 0x00ff00);
83
for ($x=0; $x<6; $x++) {
84
for ($y=0; $y<6; $y++) {
85
$p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00);
89
echo "Outside 2: ok\n";
92
$im = imagecreatetruecolor(6,6);
93
imagefill($im, 0,0, 0xffffff);
94
imageline($im, -1, -1, 4,4, 0x00ff00);
96
for ($x=0; $x<5; $x++) {
97
for ($y=0; $y<5; $y++) {
98
$p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00);
102
echo "Outside 2: ok\n";
109
Warning: imageline() expects exactly 6 parameters, 5 given in %s on line %d