7 $width =($pad +
$size +
$pad);
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 (
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);
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);
31 $cr2->set_line_width (1);
32 $cr2->move_to ($patwidth/6.0, 0);
34 $cr2->line_to (0, $patheight/6.0);
35 $cr2->set_source_rgb (1, 0, 0);
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);
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);
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);
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);
60 $cr2->move_to ($patwidth/4.0, 0);
61 $cr2->line_to ($patwidth/4.0, $patwidth);
64 $pattern = new CairoSurfacePattern ($pat_surface);
66 $mat = new CairoMatrix();
67 $mat->scale ( 2, 1.5);
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);
75 $sur->write_to_png("meta-surface-pattern-php.png");