Added some test cases ....
[phpCairo.git] / testcases / phpCairo / leaky-dashed-rectangle.php
blob9436ae9149ed5ecd3efccae61c8d2ae3d9e85cda
1 <?
2 $width = 60;
3 $height = 60;
4 $sur = new CairoImageSurface(FORMAT_ARGB32, $width, $height);
5 $con = new CairoContext($sur);
7 $dash = array(4.0, 2.0);
9 $con->set_source_rgb ( 1, 1, 1);
10 $con->paint ();
12 $con->set_source_rgb ( 0., 0., 0);
14 $con->translate ( 0.5, .5);
15 $con->set_line_width ( 1); /* This is vital to reproduce the bug. */
17 /* First check simple rectangles */
18 $con->set_source_rgb ( 0., 0., 0);
19 $con->rectangle ( -$width/4, -$height/4, $width, $height);
20 $con->stroke ();
21 $con->rectangle ( $width+$width/4, -$height/4, -$width, $height);
22 $con->stroke ();
23 $con->rectangle ( -$width/4, $height+$height/4, $width, -$height);
24 $con->stroke ();
25 $con->rectangle ( $width+$width/4, $height+$height/4, -$width, -$height);
26 $con->stroke ();
28 $con->set_dash ( $dash, 2, 0);
30 /* And now dashed. */
31 $con->set_source_rgb ( 1., 0., 0);
32 $con->rectangle ( -$width/4, -$height/4, $width, $height);
33 $con->stroke ();
34 $con->set_source_rgb ( 0., 1., 0);
35 $con->rectangle ( $width+$width/4, -$height/4, -$width, $height);
36 $con->stroke ();
37 $con->set_source_rgb ( 0., 0., 1);
38 $con->rectangle ( -$width/4, $height+$height/4, $width, -$height);
39 $con->stroke ();
40 $con->set_source_rgb ( 1., 1., 0);
41 $con->rectangle ( $width+$width/4, $height+$height/4, -$width, -$height);
42 $con->stroke ();
43 $sur->write_to_png("leaky-dashed-rectangle-php.png");