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->select_font_face("Bitstream Vera Sans");
11 $con->set_font_size(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->add_color_stop_rgba(0.2,0,0,1,1);
21 $pat->add_color_stop_rgba(0.8,0,0,1,0);
23 $con->set_source($pat);
24 $con->rectangle($x, $y, $width, $height);
26 $con->set_operator($op);
27 $con->set_source_rgb(1,0,0);
29 $con->line_to($x+
$width, $y);
30 $con->line_to($x, $y+
$height);
35 $wi = floor($width * 0.9);
36 $he = floor($height * 0.9);
40 //$stemp = $con->get_group_target();
41 $msur = $sur->create_similar(CONTENT_ALPHA
, $wi, $he);
43 $c2 = new CairoContext($msur);
45 $c2->set_source_rgba(0,0,0,0);
46 $c2->set_operator(OPERATOR_SOURCE
);
50 $c2->set_source_rgb(1,1,1);
51 $c2->arc(0.5 * $wi, 0.5 * $he, 0.45 * $he, 0, 2 * M_PI
);
55 $con->mask_surface($msur, $x, $y);
61 $con->set_font_size(0.9 * $height);
62 $ext = $con->text_extents("FG");
63 $con->move_to($x +
floor(($width - $ext["width"])/2 +
0.5) - $ext["x_bearing"], $y +
floor(($height - $ext["height"])/2 +
0.5) - $ext["y_bearing"]);
64 $con->show_text("FG");
68 $wi = floor($width * 9 / 10);
69 $he = floor($height * 9 / 10);
73 $con->move_to($x, $y);
74 $con->line_to($x, $y +
$he);
75 $con->line_to($x +
$wi/2, $y +
3 * $he/4);
76 $con->line_to($x +
$wi, $y +
$he);
77 $con->line_to($x+
$wi, $y);
78 $con->line_to($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->write_to_png("clip-operator-php.png");