Added some test cases ....
[phpCairo.git] / testcases / phpCairo / meta-surface-pattern.php
blob6dd5a06925e306df421a5bc39ec67c433bba5d14
1 <?
3 $patwidth = 120;
4 $patheight =120;
5 $size =($patwidth*2);
6 $pad =2;
7 $width =($pad + $size + $pad);
8 $height =$width;
10 $sur = new CairoImageSurface(FORMAT_ARGB32, $width, $height);
11 $con = new CairoContext($sur);
12 //$s = new CairoImageSurface(FORMAT_ARGB32, $width, $height);
15 $con->translate ( $pad, $pad);
17 $pat_surface = $sur->create_similar (
18 CONTENT_COLOR_ALPHA,
19 $patwidth, $patheight);
21 $cr2 = new CairoContext($pat_surface);
23 $cr2->set_source_rgba (1, 0, 1, 0.5);
24 $cr2->rectangle ($patwidth/6.0, $patheight/6.0, $patwidth/4.0, $patheight/4.0);
25 $cr2->fill ();
27 $cr2->set_source_rgba (0, 1, 1, 0.5);
28 $cr2->rectangle ($patwidth/2.0, $patheight/2.0, $patwidth/4.0, $patheight/4.0);
29 $cr2->fill ();
31 $cr2->set_line_width (1);
32 $cr2->move_to ($patwidth/6.0, 0);
33 $cr2->line_to (0, 0);
34 $cr2->line_to (0, $patheight/6.0);
35 $cr2->set_source_rgb (1, 0, 0);
36 $cr2->stroke ();
37 $cr2->move_to ($patwidth/6.0, $patheight);
38 $cr2->line_to (0, $patheight);
39 $cr2->line_to (0, 5*$patheight/6.0);
40 $cr2->set_source_rgb (0, 1, 0);
41 $cr2->stroke ();
42 $cr2->move_to (5*$patwidth/6.0, 0);
43 $cr2->line_to ($patwidth, 0);
44 $cr2->line_to ($patwidth, $patheight/6.0);
45 $cr2->set_source_rgb (0, 0, 1);
46 $cr2->stroke ();
47 $cr2->move_to (5*$patwidth/6.0, $patheight);
48 $cr2->line_to ($patwidth, $patheight);
49 $cr2->line_to ($patwidth, 5*$patheight/6.0);
50 $cr2->set_source_rgb (1, 1, 0);
51 $cr2->stroke ();
53 $cr2->set_source_rgb (0.5, 0.5, 0.5);
54 $cr2->set_line_width ($patwidth/10.0);
56 $cr2->move_to (0, $patheight/4.0);
57 $cr2->line_to ($patwidth, $patheight/4.0);
58 $cr2->stroke ();
60 $cr2->move_to ($patwidth/4.0, 0);
61 $cr2->line_to ($patwidth/4.0, $patwidth);
62 $cr2->stroke ();
64 $pattern = new CairoSurfacePattern ($pat_surface);
66 $mat = new CairoMatrix();
67 $mat->scale ( 2, 1.5);
68 $mat->rotate ( 1);
69 $mat->translate ( -$patwidth/4.0, -$patwidth/2.0);
70 $pattern->set_matrix ( $mat);
71 $pattern->set_extend ( EXTEND_NONE);
73 $con->set_source ( $pattern);
74 $con->paint ();
75 $sur->write_to_png("meta-surface-pattern-php.png");