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->createSimilar (
19 $patwidth, $patheight);
21 $cr2 = new CairoContext($pat_surface);
23 $cr2->setSourceRgba (1, 0, 1, 0.5);
24 $cr2->rectangle ($patwidth/6.0, $patheight/6.0, $patwidth/4.0, $patheight/4.0);
27 $cr2->setSourceRgba (0, 1, 1, 0.5);
28 $cr2->rectangle ($patwidth/2.0, $patheight/2.0, $patwidth/4.0, $patheight/4.0);
31 $cr2->setLineWidth (1);
32 $cr2->moveTo ($patwidth/6.0, 0);
34 $cr2->lineTo (0, $patheight/6.0);
35 $cr2->setSourceRgb (1, 0, 0);
37 $cr2->moveTo ($patwidth/6.0, $patheight);
38 $cr2->lineTo (0, $patheight);
39 $cr2->lineTo (0, 5*$patheight/6.0);
40 $cr2->setSourceRgb (0, 1, 0);
42 $cr2->moveTo (5*$patwidth/6.0, 0);
43 $cr2->lineTo ($patwidth, 0);
44 $cr2->lineTo ($patwidth, $patheight/6.0);
45 $cr2->setSourceRgb (0, 0, 1);
47 $cr2->moveTo (5*$patwidth/6.0, $patheight);
48 $cr2->lineTo ($patwidth, $patheight);
49 $cr2->lineTo ($patwidth, 5*$patheight/6.0);
50 $cr2->setSourceRgb (1, 1, 0);
53 $cr2->setSourceRgb (0.5, 0.5, 0.5);
54 $cr2->setLineWidth ($patwidth/10.0);
56 $cr2->moveTo (0, $patheight/4.0);
57 $cr2->lineTo ($patwidth, $patheight/4.0);
60 $cr2->moveTo ($patwidth/4.0, 0);
61 $cr2->lineTo ($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->setMatrix ( $mat);
71 $pattern->setExtend ( EXTEND_NONE
);
73 $con->setSource ( $pattern);
75 $sur->writeToPng("meta-surface-pattern-php.png");