3 $sur = new CairoImageSurface(FORMAT_ARGB32
, $size, $size);
4 $con = new CairoContext($sur);
5 $con->setSourceRgb ( 1, 1, 1); /* White */
8 $con->moveTo ( $size, 0);
9 $con->lineTo ( $size, $size);
10 $con->lineTo ( 0, $size);
12 $con->setSourceRgb ( 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->setMatrix ( $matrix);
23 $con->setSource ($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->writeToPng("self-copy-php.png");