Added some test cases ....
[phpCairo.git] / testcases / phpCairo / degenerate-path.php
blob21d001fb4c4a6ebab13b8f8128650c5c99277806
1 <?
2 $sur = new CairoImageSurface(FORMAT_ARGB32,3*(3+6+3), 8*(6+3) + 3);
3 $con = new CairoContext($sur);
6 $cap = array(LINE_CAP_ROUND, LINE_CAP_SQUARE, LINE_CAP_BUTT);
8 $dash = array(2.0, 2.0);
9 $dash_long = array(6.0, 6.0);
11 $con->set_source_rgb ( 1, 0, 0);
13 for ($i=0; $i<3; $i++) {
14 $con->save ();
16 $con->set_line_cap ( $cap[$i]);
18 /* simple degenerate paths */
19 $con->set_line_width ( 6);
20 $con->move_to ( 6, 6);
21 $con->line_to ( 6, 6);
22 $con->stroke ();
24 $con->translate ( 0, 3*3);
25 $con->move_to ( 6, 6);
26 $con->close_path ();
27 $con->stroke ();
29 /* degenerate paths starting with dash on */
30 $con->set_dash ( $dash, 2, 0.);
32 $con->translate ( 0, 3*3);
33 $con->move_to ( 6, 6);
34 $con->line_to ( 6, 6);
35 $con->stroke ();
37 $con->translate ( 0, 3*3);
38 $con->move_to ( 6, 6);
39 $con->close_path ();
40 $con->stroke ();
42 /* degenerate paths starting with dash off */
43 /* these should not draw anything */
44 $con->set_dash ( $dash, 2, 2.);
46 $con->translate ( 0, 3*3);
47 $con->move_to ( 6, 6);
48 $con->line_to ( 6, 6);
49 $con->stroke ();
51 $con->translate ( 0, 3*3);
52 $con->move_to ( 6, 6);
53 $con->close_path ();
54 $con->stroke ();
56 /* this should draw a single degenerate sub-path
57 * at the end of the path */
58 $con->set_dash ( $dash_long, 2, 6.);
60 $con->translate ( 0, 3*3);
61 $con->move_to ( 6 + 6.0, 6);
62 $con->line_to ( 6, 6);
63 $con->stroke ();
65 /* this should draw a single degenerate sub-path
66 * at the end of the path. The difference between this
67 * and the above is that this ends with a degenerate sub-path*/
68 $con->set_dash ( $dash_long, 2, 6.);
70 $con->translate ( 0, 3*3);
71 $con->move_to ( 6 + 6.0, 6);
72 $con->line_to ( 6, 6);
73 $con->line_to ( 6, 6);
74 $con->stroke ();
76 $con->restore ();
78 $con->translate ( 3+6+3, 0);
80 $sur->write_to_png("degenerate-path-php.png");