Examples updated to the latest Camel Case .. Was a pain converting them
[phpCairo.git] / testcases / phpCairo / meta-surface-pattern.php
blob06cf8bb8549151274f5660dc56dbe48cd40d4d52
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->createSimilar (
18 CONTENT_COLOR_ALPHA,
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);
25 $cr2->fill ();
27 $cr2->setSourceRgba (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->setLineWidth (1);
32 $cr2->moveTo ($patwidth/6.0, 0);
33 $cr2->lineTo (0, 0);
34 $cr2->lineTo (0, $patheight/6.0);
35 $cr2->setSourceRgb (1, 0, 0);
36 $cr2->stroke ();
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);
41 $cr2->stroke ();
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);
46 $cr2->stroke ();
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);
51 $cr2->stroke ();
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);
58 $cr2->stroke ();
60 $cr2->moveTo ($patwidth/4.0, 0);
61 $cr2->lineTo ($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->setMatrix ( $mat);
71 $pattern->setExtend ( EXTEND_NONE);
73 $con->setSource ( $pattern);
74 $con->paint ();
75 $sur->writeToPng("meta-surface-pattern-php.png");