xref: /PHP-7.2/ext/gd/tests/dashedlines.phpt (revision 17ccbeec)
1--TEST--
2imageline, dashed
3--SKIPIF--
4<?php
5        if (!function_exists('imagecreatefromstring')) die("skip gd extension not available\n");
6?>
7--FILE--
8<?php
9$im = imagecreatetruecolor(6,6);
10imagefill($im, 0,0, 0xffffff);
11
12$r  = 0xff0000;
13$b = 0x0000ff;
14
15$style = array($r, $b);
16imagesetstyle($im, $style);
17
18// Horizontal line
19imageline($im, 0,5, 5,5, IMG_COLOR_STYLED);
20$p1 = imagecolorat($im, 0,5) == $r;
21$p2 = imagecolorat($im, 1,5) == $b;
22$p3 = imagecolorat($im, 2,5) == $r;
23$p4 = imagecolorat($im, 3,5) == $b;
24$p5 = imagecolorat($im, 4,5) == $r;
25$p5 = imagecolorat($im, 5,5) == $b;
26
27
28if ($p1 && $p2 && $p3 && $p4 && $p5) {
29	echo "Horizontal: ok\n";
30}
31imagedestroy($im);
32
33$im = imagecreatetruecolor(6,6);
34imagefill($im, 0,0, 0xffffff);
35
36$style = array($r, $b);
37imagesetstyle($im, $style);
38
39
40imageline($im, 2,0, 2,5, IMG_COLOR_STYLED);
41$p1 = imagecolorat($im, 2,0) == $r;
42$p2 = imagecolorat($im, 2,1) == $b;
43$p3 = imagecolorat($im, 2,2) == $r;
44$p4 = imagecolorat($im, 2,3) == $b;
45$p5 = imagecolorat($im, 2,4) == $r;
46$p6 = imagecolorat($im, 2,5) == $b;
47
48if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) {
49	echo "Vertical: ok\n";
50}
51imagedestroy($im);
52
53
54$im = imagecreatetruecolor(6,6);
55imagefill($im, 0,0, 0xffffff);
56
57$style = array($r, $b);
58imagesetstyle($im, $style);
59
60imageline($im, 0,0, 5,5, IMG_COLOR_STYLED);
61$p1 = imagecolorat($im, 0,0) == $r;
62$p2 = imagecolorat($im, 1,1) == $b;
63$p3 = imagecolorat($im, 2,2) == $r;
64$p4 = imagecolorat($im, 3,3) == $b;
65$p5 = imagecolorat($im, 4,4) == $r;
66$p6 = imagecolorat($im, 5,5) == $b;
67
68if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) {
69	echo "Diagonal: ok\n";
70}
71imagedestroy($im);
72
73
74?>
75--EXPECTF--
76Horizontal: ok
77Vertical: ok
78Diagonal: ok
79