3 $sur = new CairoImageSurface(FORMAT_ARGB32
, $size, $size);
4 $con = new CairoContext($sur);
5 $con->set_source_rgb ( 1, 1, 1); /* White */
8 $con->move_to ( $size, 0);
9 $con->line_to ( $size, $size);
10 $con->line_to ( 0, $size);
12 $con->set_source_rgb ( 0, 0, 0);
15 /* Create a pattern with the target surface as the source,
18 $pattern = new CairoSurfacePattern ($sur);
19 $matrix = new CairoMatrix();
20 $matrix->translate ( - $size / 2, - $size / 2);
21 $pattern->set_matrix ( $matrix);
23 $con->set_source ($pattern);
25 /* Copy two rectangles from the upper-left quarter of the image to
26 * the lower right. It will work if we use $con->fill(), but the
27 * $con->clip() $con->paint() combination fails because the clip
28 * on the surface as a destination affects it as the source as
32 2 * $size / 4, 2 * $size / 4,
33 $size / 4, $size / 4);
35 3 * $size / 4, 3 * $size / 4,
36 $size / 4, $size / 4);
39 $sur->write_to_png("self-copy-php.png");