7 function set_solid_pattern ($x, $y)
10 $con->set_source_rgb (1.0, 0, 0.0);
13 function set_gradient_pattern ($x, $y)
15 global $con,$width,$height;
17 $pat = new CairoLinearGradient ($x, $y, $x + $width, $y + $height);
18 $pat->add_color_stop_rgba (0.2, 1, 0, 0, 1);
19 $pat->add_color_stop_rgba ( 0.8, 1, 0, 0, 0.0);
20 $con->set_source ($pat);
24 function draw_mask ($x, $y)
27 global $con,$width,$height;
28 double $wi = floor(0.9 * $width);
29 double $he = floor(0.9 * $height);
32 new $s = new CairoImageSurface(FORMAT_ARGB32, 1, 1);
33 $s->create_similar ($con->get_group_target(),
36 $con2 = new CairoContext($s);
38 $con2->set_source_rgb (1, 1, 1); /* white */
40 $con2->arc (0.5 * $wi, 0.5 * $he, 0.45 * $he, 0, 2 * M_PI);
44 $con->mask_surface ($s, $x, $y);
49 function draw_glyphs ($x, $y)
52 global $con,$width,$height;
53 $con->set_font_size (0.8 * $height);
55 $extents = $con->text_extents ("FG");
57 $x + floor (($width - $extents["width"]) / 2 + 0.5) - $extents["x_bearing"],
58 $y + floor (($height - $extents["height"]) / 2 + 0.5) - $extents["y_bearing"]);
59 $con->show_text ("FG");
62 function draw_polygon ($x, $y)
64 global $con,$width,$height;
66 $wi = floor(0.9 * $width);
67 $he = floor(0.9 * $height);
72 $con->move_to ($x, $y);
73 $con->line_to ($x, $y + $he);
74 $con->line_to ($x + $wi / 2, $y + 3 * $he / 4);
75 $con->line_to ($x + $wi, $y + $he);
76 $con->line_to ($x + $wi, $y);
77 $con->line_to ($x + $wi / 2, $y + $he / 4);
82 function draw_rects ($x, $y)
84 global $con,$width,$height;
86 $block_width = floor(0.33 * $width + 0.5);
87 $block_height = floor(0.33 * $height + 0.5);
90 for ($i = 0; $i < 3; $i++)
91 for ($j = 0; $j < 3; $j++)
92 if (($i + $j) % 2 == 0)
94 $x + $block_width * $i, $y + $block_height * $j,
95 $block_width, $block_height);
100 $con->select_font_face (cr, "Bitstream Vera Sans",
101 CAIRO_FONT_SLANT_NORMAL,
102 CAIRO_FONT_WEIGHT_NORMAL);
104 for ($j = 0; $j < 4; $j++) {
105 for ($i = 0; $i < 2; $i++) {
106 $x = $i * ($width + $pad) + $pad;
107 $y = $j * ($height + $pad) + $pad;
111 $pat = new CairoLinearGradient ($x + $width, $y,
113 $pat->add_color_stop_rgba (0.2,
114 0.0, 0.0, 1.0, 1.0); /* Solid blue */
115 $pat->add_color_stop_rgba ( 0.8,
116 0.0, 0.0, 1.0, 0.0); /* Transparent blue */
117 $con->set_source ($pat);
120 $con->rectangle ($x, $y, $width, $height);
121 $con->fill_preserve ();
124 $con->set_operator (OPERATOR_CLEAR);
125 //pattern_funcs[i] ($x, $y);
127 //draw_funcs[j] (cr, x, y);