5 $noperator = 1 + OPERATOR_SATURATE
- OPERATOR_CLEAR
;
6 $imagewidth = $noperator * ($width +
$pad) +
$pad;
7 $imageheight = 4 * ($height +
$pad) +
$pad;
8 $sur = new CairoImageSurface(FORMAT_ARGB32
, $imagewidth, $imageheight);
9 $con = new CairoContext($sur);
10 $con->selectFontFace("Bitstream Vera Sans");
11 $con->setFontSize(0.9 * $height);
13 for($i=0; $i < 4; $i++
) {
14 for($op = OPERATOR_CLEAR
; $op < $noperator; $op++
) {
15 $x = $op *($width +
$pad) +
$pad;
16 $y = $i * ($height +
$pad) +
$pad;
19 $pat = new CairoLinearGradient($x +
$width, $y, $x, $y +
$height);
20 $pat->addColorStopRgba(0.2,0,0,1,1);
21 $pat->addColorStopRgba(0.8,0,0,1,0);
23 $con->setSource($pat);
24 $con->rectangle($x, $y, $width, $height);
26 $con->setOperator($op);
27 $con->setSourceRgb(1,0,0);
29 $con->lineTo($x+
$width, $y);
30 $con->lineTo($x, $y+
$height);
35 $wi = floor($width * 0.9);
36 $he = floor($height * 0.9);
40 //$stemp = $con->get_group_target();
41 $msur = $sur->createSimilar(CONTENT_ALPHA
, $wi, $he);
43 $c2 = new CairoContext($msur);
45 $c2->setSourceRgba(0,0,0,0);
46 $c2->setOperator(OPERATOR_SOURCE
);
50 $c2->setSourceRgb(1,1,1);
51 $c2->arc(0.5 * $wi, 0.5 * $he, 0.45 * $he, 0, 2 * M_PI
);
55 $con->maskSurface($msur, $x, $y);
61 $con->setFontSize(0.9 * $height);
62 $ext = $con->textExtents("FG");
63 $con->moveTo($x +
floor(($width - $ext["width"])/2 +
0.5) - $ext["x_bearing"], $y +
floor(($height - $ext["height"])/2 +
0.5) - $ext["y_bearing"]);
68 $wi = floor($width * 9 / 10);
69 $he = floor($height * 9 / 10);
74 $con->lineTo($x, $y +
$he);
75 $con->lineTo($x +
$wi/2, $y +
3 * $he/4);
76 $con->lineTo($x +
$wi, $y +
$he);
77 $con->lineTo($x+
$wi, $y);
78 $con->lineTo($x +
$wi/2, $y +
$he/4);
84 $bw = floor(0.33 * $width +
0.5);
85 $bh = floor(0.33 * $height +
0.5);
87 for($t1 = 0; $t1 < 3; $t1++
)
88 for($t2 = 0; $t2 < 3; $t2++
)
89 if (($t1 +
$t2) %
2 == 0)
90 $con->rectangle($x +
$bw*$t1, $y +
$bh*$t2, $bw, $bh);
99 $sur->writeToPng("clip-operator-php.png");