[cairo-commit] [cairo-www] 5 commits - src/cairo-banner.svg src/samples src/samples.mdwn templates/cairo_sample.tmpl templates/feedlink.tmpl
Carl Worth
cworth at freedesktop.org
Fri Aug 3 10:44:50 PDT 2007
src/cairo-banner.svg | 4 +-
src/samples.mdwn | 23 ++++++++++++++
src/samples/arc.mdwn | 23 ++++++++++++++
src/samples/arc.png |binary
src/samples/arc_negative.mdwn | 23 ++++++++++++++
src/samples/arc_negative.png |binary
src/samples/clip.mdwn | 15 +++++++++
src/samples/clip.png |binary
src/samples/clip_image.mdwn | 18 +++++++++++
src/samples/clip_image.png |binary
src/samples/curve_rectangle.mdwn | 56 ++++++++++++++++++++++++++++++++++++
src/samples/curve_rectangle.png |binary
src/samples/curve_to.mdwn | 17 ++++++++++
src/samples/curve_to.png |binary
src/samples/dash.mdwn | 18 +++++++++++
src/samples/dash.png |binary
src/samples/fill_and_stroke2.mdwn | 18 +++++++++++
src/samples/fill_and_stroke2.png |binary
src/samples/gradient.mdwn | 19 ++++++++++++
src/samples/gradient.png |binary
src/samples/image.mdwn | 17 ++++++++++
src/samples/image.png |binary
src/samples/imagepattern.mdwn | 28 ++++++++++++++++++
src/samples/imagepattern.png |binary
src/samples/multi_segment_caps.mdwn | 13 ++++++++
src/samples/multi_segment_caps.png |binary
src/samples/set_line_cap.mdwn | 19 ++++++++++++
src/samples/set_line_cap.png |binary
src/samples/set_line_join.mdwn | 19 ++++++++++++
src/samples/set_line_join.png |binary
src/samples/text.mdwn | 22 ++++++++++++++
src/samples/text.png |binary
src/samples/text_align_center.mdwn | 28 ++++++++++++++++++
src/samples/text_align_center.png |binary
src/samples/text_extents.mdwn | 29 ++++++++++++++++++
src/samples/text_extents.png |binary
templates/cairo_sample.tmpl | 35 ++++++++++++++++++++++
templates/feedlink.tmpl | 12 +++++++
38 files changed, 454 insertions(+), 2 deletions(-)
New commits:
commit ed59bf336aeda85d1619a8d2e08e90338c40dc67
Author: Nis Martensen <nis.martensen at web.de>
Date: Fri Aug 3 18:04:46 2007 +0200
Avoid an empty <div id="feedlink">\n\n\n</div>
diff --git a/templates/feedlink.tmpl b/templates/feedlink.tmpl
index 2963156..9df8f77 100644
--- a/templates/feedlink.tmpl
+++ b/templates/feedlink.tmpl
@@ -1,8 +1,20 @@
+<TMPL_IF NAME="RSSURL">
+<div id="feedlink">
+<TMPL_ELSE>
+<TMPL_IF NAME="ATOMURL">
<div id="feedlink">
+</TMPL_IF>
+</TMPL_IF>
<TMPL_IF NAME="RSSURL">
<a class="feedbutton" type="application/rss+xml" href="<TMPL_VAR NAME=RSSURL>">RSS</a>
</TMPL_IF>
<TMPL_IF NAME="ATOMURL">
<a class="feedbutton" type="application/atom+xml" href="<TMPL_VAR NAME=ATOMURL>">Atom</a>
</TMPL_IF>
+<TMPL_IF NAME="RSSURL">
+</div>
+<TMPL_ELSE>
+<TMPL_IF NAME="ATOMURL">
</div>
+</TMPL_IF>
+</TMPL_IF>
commit 65b2d04bb49ffd3302430ab2dc213c67d54740f5
Author: Nis Martensen <nis.martensen at web.de>
Date: Fri Aug 3 18:02:54 2007 +0200
Add sample code snippets
diff --git a/src/samples/arc.mdwn b/src/samples/arc.mdwn
new file mode 100644
index 0000000..fa8c853
--- /dev/null
+++ b/src/samples/arc.mdwn
@@ -0,0 +1,23 @@
+<div class="tutright">[[img "arc.png" link="no"]]</div>
+ double xc = 128.0;
+ double yc = 128.0;
+ double radius = 100.0;
+ double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */
+ double angle2 = 180.0 * (M_PI/180.0); /* in radians */
+
+ cairo_set_line_width (cr, 10.0);
+ cairo_arc (cr, xc, yc, radius, angle1, angle2);
+ cairo_stroke (cr);
+
+ /* draw helping lines */
+ cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
+ cairo_set_line_width (cr, 6.0);
+
+ cairo_arc (cr, xc, yc, 10.0, 0, 2*M_PI);
+ cairo_fill (cr);
+
+ cairo_arc (cr, xc, yc, radius, angle1, angle1);
+ cairo_line_to (cr, xc, yc);
+ cairo_arc (cr, xc, yc, radius, angle2, angle2);
+ cairo_line_to (cr, xc, yc);
+ cairo_stroke (cr);
diff --git a/src/samples/arc_negative.mdwn b/src/samples/arc_negative.mdwn
new file mode 100644
index 0000000..d5cb376
--- /dev/null
+++ b/src/samples/arc_negative.mdwn
@@ -0,0 +1,23 @@
+<div class="tutright">[[img "arc_negative.png" link="no"]]</div>
+ double xc = 128.0;
+ double yc = 128.0;
+ double radius = 100.0;
+ double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */
+ double angle2 = 180.0 * (M_PI/180.0); /* in radians */
+
+ cairo_set_line_width (cr, 10.0);
+ cairo_arc_negative (cr, xc, yc, radius, angle1, angle2);
+ cairo_stroke (cr);
+
+ /* draw helping lines */
+ cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
+ cairo_set_line_width (cr, 6.0);
+
+ cairo_arc (cr, xc, yc, 10.0, 0, 2*M_PI);
+ cairo_fill (cr);
+
+ cairo_arc (cr, xc, yc, radius, angle1, angle1);
+ cairo_line_to (cr, xc, yc);
+ cairo_arc (cr, xc, yc, radius, angle2, angle2);
+ cairo_line_to (cr, xc, yc);
+ cairo_stroke (cr);
diff --git a/src/samples/clip.mdwn b/src/samples/clip.mdwn
new file mode 100644
index 0000000..834b7b7
--- /dev/null
+++ b/src/samples/clip.mdwn
@@ -0,0 +1,15 @@
+<div class="tutright">[[img "clip.png" link="no"]]</div>
+ cairo_arc (cr, 128.0, 128.0, 76.8, 0, 2 * M_PI);
+ cairo_clip (cr);
+
+ cairo_new_path (cr); /* current path is not
+ consumed by cairo_clip() */
+ cairo_rectangle (cr, 0, 0, 256, 256);
+ cairo_fill (cr);
+ cairo_set_source_rgb (cr, 0, 1, 0);
+ cairo_move_to (cr, 0, 0);
+ cairo_line_to (cr, 256, 256);
+ cairo_move_to (cr, 256, 0);
+ cairo_line_to (cr, 0, 256);
+ cairo_set_line_width (cr, 10.0);
+ cairo_stroke (cr);
diff --git a/src/samples/clip_image.mdwn b/src/samples/clip_image.mdwn
new file mode 100644
index 0000000..e98f2f0
--- /dev/null
+++ b/src/samples/clip_image.mdwn
@@ -0,0 +1,18 @@
+<div class="tutright">[[img "clip_image.png" link="no"]]</div>
+ int w, h;
+ cairo_surface_t *image;
+
+ cairo_arc (cr, 128.0, 128.0, 76.8, 0, 2*M_PI);
+ cairo_clip (cr);
+ cairo_new_path (cr); /* path not consumed by clip()*/
+
+ image = cairo_image_surface_create_from_png ("data/romedalen.png");
+ w = cairo_image_surface_get_width (image);
+ h = cairo_image_surface_get_height (image);
+
+ cairo_scale (cr, 256.0/w, 256.0/h);
+
+ cairo_set_source_surface (cr, image, 0, 0);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (image);
diff --git a/src/samples/curve_rectangle.mdwn b/src/samples/curve_rectangle.mdwn
new file mode 100644
index 0000000..e919f54
--- /dev/null
+++ b/src/samples/curve_rectangle.mdwn
@@ -0,0 +1,56 @@
+<div class="tutright">[[img "curve_rectangle.png" link="no"]]</div>
+ /* a custom shape that could be wrapped in a function */
+ double x0 = 25.6, /* parameters like cairo_rectangle */
+ y0 = 25.6,
+ rect_width = 204.8,
+ rect_height = 204.8,
+ radius = 102.4; /* and an approximate curvature radius */
+
+ double x1,y1;
+
+ x1=x0+rect_width;
+ y1=y0+rect_height;
+ if (!rect_width || !rect_height)
+ return;
+ if (rect_width/2<radius) {
+ if (rect_height/2<radius) {
+ cairo_move_to (cr, x0, (y0 + y1)/2);
+ cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
+ cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
+ } else {
+ cairo_move_to (cr, x0, y0 + radius);
+ cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
+ cairo_line_to (cr, x1 , y1 - radius);
+ cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
+ }
+ } else {
+ if (rect_height/2<radius) {
+ cairo_move_to (cr, x0, (y0 + y1)/2);
+ cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
+ cairo_line_to (cr, x1 - radius, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
+ cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
+ cairo_line_to (cr, x0 + radius, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
+ } else {
+ cairo_move_to (cr, x0, y0 + radius);
+ cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
+ cairo_line_to (cr, x1 - radius, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
+ cairo_line_to (cr, x1 , y1 - radius);
+ cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
+ cairo_line_to (cr, x0 + radius, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
+ }
+ }
+ cairo_close_path (cr);
+
+ cairo_set_source_rgb (cr, 0.5, 0.5, 1);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgba (cr, 0.5, 0, 0, 0.5);
+ cairo_set_line_width (cr, 10.0);
+ cairo_stroke (cr);
diff --git a/src/samples/curve_to.mdwn b/src/samples/curve_to.mdwn
new file mode 100644
index 0000000..3b80183
--- /dev/null
+++ b/src/samples/curve_to.mdwn
@@ -0,0 +1,17 @@
+<div class="tutright">[[img "curve_to.png" link="no"]]</div>
+ double x=25.6, y=128.0;
+ double x1=102.4, y1=230.4,
+ x2=153.6, y2=25.6,
+ x3=230.4, y3=128.0;
+
+ cairo_move_to (cr, x, y);
+ cairo_curve_to (cr, x1, y1, x2, y2, x3, y3);
+
+ cairo_set_line_width (cr, 10.0);
+ cairo_stroke (cr);
+
+ cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
+ cairo_set_line_width (cr, 6.0);
+ cairo_move_to (cr,x,y); cairo_line_to (cr,x1,y1);
+ cairo_move_to (cr,x2,y2); cairo_line_to (cr,x3,y3);
+ cairo_stroke (cr);
diff --git a/src/samples/dash.mdwn b/src/samples/dash.mdwn
new file mode 100644
index 0000000..ce195a3
--- /dev/null
+++ b/src/samples/dash.mdwn
@@ -0,0 +1,18 @@
+<div class="tutright">[[img "dash.png" link="no"]]</div>
+ double dashes[] = {50.0, /* ink */
+ 10.0, /* skip */
+ 10.0, /* ink */
+ 10.0 /* skip*/
+ };
+ int ndash = sizeof (dashes)/sizeof(dashes[0]);
+ double offset = -50.0;
+
+ cairo_set_dash (cr, dashes, ndash, offset);
+ cairo_set_line_width (cr, 10.0);
+
+ cairo_move_to (cr, 128.0, 25.6);
+ cairo_line_to (cr, 230.4, 230.4);
+ cairo_rel_line_to (cr, -102.4, 0.0);
+ cairo_curve_to (cr, 51.2, 230.4, 51.2, 128.0, 128.0, 128.0);
+
+ cairo_stroke (cr);
diff --git a/src/samples/fill_and_stroke2.mdwn b/src/samples/fill_and_stroke2.mdwn
new file mode 100644
index 0000000..872d5d4
--- /dev/null
+++ b/src/samples/fill_and_stroke2.mdwn
@@ -0,0 +1,18 @@
+<div class="tutright">[[img "fill_and_stroke2.png" link="no"]]</div>
+ cairo_move_to (cr, 128.0, 25.6);
+ cairo_line_to (cr, 230.4, 230.4);
+ cairo_rel_line_to (cr, -102.4, 0.0);
+ cairo_curve_to (cr, 51.2, 230.4, 51.2, 128.0, 128.0, 128.0);
+ cairo_close_path (cr);
+
+ cairo_move_to (cr, 64.0, 25.6);
+ cairo_rel_line_to (cr, 51.2, 51.2);
+ cairo_rel_line_to (cr, -51.2, 51.2);
+ cairo_rel_line_to (cr, -51.2, -51.2);
+ cairo_close_path (cr);
+
+ cairo_set_line_width (cr, 10.0);
+ cairo_set_source_rgb (cr, 0, 0, 1);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_stroke (cr);
diff --git a/src/samples/gradient.mdwn b/src/samples/gradient.mdwn
new file mode 100644
index 0000000..8c50ac6
--- /dev/null
+++ b/src/samples/gradient.mdwn
@@ -0,0 +1,19 @@
+<div class="tutright">[[img "gradient.png" link="no"]]</div>
+ cairo_pattern_t *pat;
+
+ pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
+ cairo_rectangle (cr, 0, 0, 256, 256);
+ cairo_set_source (cr, pat);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+
+ pat = cairo_pattern_create_radial (115.2, 102.4, 25.6,
+ 102.4, 102.4, 128.0);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
+ cairo_set_source (cr, pat);
+ cairo_arc (cr, 128.0, 128.0, 76.8, 0, 2 * M_PI);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
diff --git a/src/samples/image.mdwn b/src/samples/image.mdwn
new file mode 100644
index 0000000..e2eff2f
--- /dev/null
+++ b/src/samples/image.mdwn
@@ -0,0 +1,17 @@
+<div class="tutright">[[img "image.png" link="no"]]</div>
+ int w, h;
+ cairo_surface_t *image;
+
+ image = cairo_image_surface_create_from_png ("data/romedalen.png");
+ w = cairo_image_surface_get_width (image);
+ h = cairo_image_surface_get_height (image);
+
+ cairo_translate (cr, 128.0, 128.0);
+ cairo_rotate (cr, 45* M_PI/180);
+ cairo_scale (cr, 256.0/w, 256.0/h);
+ cairo_translate (cr, -0.5*w, -0.5*h);
+
+ cairo_set_source_surface (cr, image, 0, 0);
+ cairo_paint (cr);
+ cairo_surface_destroy (image);
+
diff --git a/src/samples/imagepattern.mdwn b/src/samples/imagepattern.mdwn
new file mode 100644
index 0000000..2e9635c
--- /dev/null
+++ b/src/samples/imagepattern.mdwn
@@ -0,0 +1,28 @@
+<div class="tutright">[[img "imagepattern.png" link="no"]]</div>
+ int w, h;
+ cairo_surface_t *image;
+ cairo_pattern_t *pattern;
+ cairo_matrix_t matrix;
+
+ image = cairo_image_surface_create_from_png ("data/romedalen.png");
+ w = cairo_image_surface_get_width (image);
+ h = cairo_image_surface_get_height (image);
+
+ pattern = cairo_pattern_create_for_surface (image);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+ cairo_translate (cr, 128.0, 128.0);
+ cairo_rotate (cr, M_PI / 4);
+ cairo_scale (cr, 1 / sqrt (2), 1 / sqrt (2));
+ cairo_translate (cr, -128.0, -128.0);
+
+ cairo_matrix_init_scale (&matrix, w/256.0 * 5.0, h/256.0 * 5.0);
+ cairo_pattern_set_matrix (pattern, &matrix);
+
+ cairo_set_source (cr, pattern);
+
+ cairo_rectangle (cr, 0, 0, 256.0, 256.0);
+ cairo_fill (cr);
+
+ cairo_pattern_destroy (pattern);
+ cairo_surface_destroy (image);
diff --git a/src/samples/multi_segment_caps.mdwn b/src/samples/multi_segment_caps.mdwn
new file mode 100644
index 0000000..3c890de
--- /dev/null
+++ b/src/samples/multi_segment_caps.mdwn
@@ -0,0 +1,13 @@
+<div class="tutright">[[img "multi_segment_caps.png" link="no"]]</div>
+ cairo_move_to (cr, 50.0, 75.0);
+ cairo_line_to (cr, 200.0, 75.0);
+
+ cairo_move_to (cr, 50.0, 125.0);
+ cairo_line_to (cr, 200.0, 125.0);
+
+ cairo_move_to (cr, 50.0, 175.0);
+ cairo_line_to (cr, 200.0, 175.0);
+
+ cairo_set_line_width (cr, 30.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke (cr);
diff --git a/src/samples/set_line_cap.mdwn b/src/samples/set_line_cap.mdwn
new file mode 100644
index 0000000..025bf94
--- /dev/null
+++ b/src/samples/set_line_cap.mdwn
@@ -0,0 +1,19 @@
+<div class="tutright">[[img "set_line_cap.png" link="no"]]</div>
+ cairo_set_line_width (cr, 30.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); /* default */
+ cairo_move_to (cr, 64.0, 50.0); cairo_line_to (cr, 64.0, 200.0);
+ cairo_stroke (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_move_to (cr, 128.0, 50.0); cairo_line_to (cr, 128.0, 200.0);
+ cairo_stroke (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+ cairo_move_to (cr, 192.0, 50.0); cairo_line_to (cr, 192.0, 200.0);
+ cairo_stroke (cr);
+
+ /* draw helping lines */
+ cairo_set_source_rgb (cr, 1, 0.2, 0.2);
+ cairo_set_line_width (cr, 2.56);
+ cairo_move_to (cr, 64.0, 50.0); cairo_line_to (cr, 64.0, 200.0);
+ cairo_move_to (cr, 128.0, 50.0); cairo_line_to (cr, 128.0, 200.0);
+ cairo_move_to (cr, 192.0, 50.0); cairo_line_to (cr, 192.0, 200.0);
+ cairo_stroke (cr);
diff --git a/src/samples/set_line_join.mdwn b/src/samples/set_line_join.mdwn
new file mode 100644
index 0000000..b63059f
--- /dev/null
+++ b/src/samples/set_line_join.mdwn
@@ -0,0 +1,19 @@
+<div class="tutright">[[img "set_line_join.png" link="no"]]</div>
+ cairo_set_line_width (cr, 40.96);
+ cairo_move_to (cr, 76.8, 84.48);
+ cairo_rel_line_to (cr, 51.2, -51.2);
+ cairo_rel_line_to (cr, 51.2, 51.2);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); /* default */
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, 76.8, 161.28);
+ cairo_rel_line_to (cr, 51.2, -51.2);
+ cairo_rel_line_to (cr, 51.2, 51.2);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, 76.8, 238.08);
+ cairo_rel_line_to (cr, 51.2, -51.2);
+ cairo_rel_line_to (cr, 51.2, 51.2);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_stroke (cr);
diff --git a/src/samples/text.mdwn b/src/samples/text.mdwn
new file mode 100644
index 0000000..7b4a801
--- /dev/null
+++ b/src/samples/text.mdwn
@@ -0,0 +1,22 @@
+<div class="tutright">[[img "text.png" link="no"]]</div>
+ cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size (cr, 90.0);
+
+ cairo_move_to (cr, 10.0, 135.0);
+ cairo_show_text (cr, "Hello");
+
+ cairo_move_to (cr, 70.0, 165.0);
+ cairo_text_path (cr, "void");
+ cairo_set_source_rgb (cr, 0.5, 0.5, 1);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_set_line_width (cr, 2.56);
+ cairo_stroke (cr);
+
+ /* draw helping lines */
+ cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
+ cairo_arc (cr, 10.0, 135.0, 5.12, 0, 2*M_PI);
+ cairo_close_path (cr);
+ cairo_arc (cr, 70.0, 165.0, 5.12, 0, 2*M_PI);
+ cairo_fill (cr);
diff --git a/src/samples/text_align_center.mdwn b/src/samples/text_align_center.mdwn
new file mode 100644
index 0000000..bcba000
--- /dev/null
+++ b/src/samples/text_align_center.mdwn
@@ -0,0 +1,28 @@
+<div class="tutright">[[img "text_align_center.png" link="no"]]</div>
+ cairo_text_extents_t extents;
+
+ const char *utf8 = "cairo";
+ double x,y;
+
+ cairo_select_font_face (cr, "Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+
+ cairo_set_font_size (cr, 52.0);
+ cairo_text_extents (cr, utf8, &extents);
+ x = 128.0-(extents.width/2 + extents.x_bearing);
+ y = 128.0-(extents.height/2 + extents.y_bearing);
+
+ cairo_move_to (cr, x, y);
+ cairo_show_text (cr, utf8);
+
+ /* draw helping lines */
+ cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
+ cairo_set_line_width (cr, 6.0);
+ cairo_arc (cr, x, y, 10.0, 0, 2*M_PI);
+ cairo_fill (cr);
+ cairo_move_to (cr, 128.0, 0);
+ cairo_rel_line_to (cr, 0, 256);
+ cairo_move_to (cr, 0, 128.0);
+ cairo_rel_line_to (cr, 256, 0);
+ cairo_stroke (cr);
diff --git a/src/samples/text_extents.mdwn b/src/samples/text_extents.mdwn
new file mode 100644
index 0000000..2e8128b
--- /dev/null
+++ b/src/samples/text_extents.mdwn
@@ -0,0 +1,29 @@
+<div class="tutright">[[img "text_extents.png" link="no"]]</div>
+ cairo_text_extents_t extents;
+
+ const char *utf8 = "cairo";
+ double x,y;
+
+ cairo_select_font_face (cr, "Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+
+ cairo_set_font_size (cr, 100.0);
+ cairo_text_extents (cr, utf8, &extents);
+
+ x=25.0;
+ y=150.0;
+
+ cairo_move_to (cr, x,y);
+ cairo_show_text (cr, utf8);
+
+ /* draw helping lines */
+ cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
+ cairo_set_line_width (cr, 6.0);
+ cairo_arc (cr, x, y, 10.0, 0, 2*M_PI);
+ cairo_fill (cr);
+ cairo_move_to (cr, x,y);
+ cairo_rel_line_to (cr, 0, -extents.height);
+ cairo_rel_line_to (cr, extents.width, 0);
+ cairo_rel_line_to (cr, extents.x_bearing, -extents.y_bearing);
+ cairo_stroke (cr);
commit 4f053eafa228b63640bba5e931cf475082dea206
Author: Nis Martensen <nis.martensen at web.de>
Date: Fri Aug 3 18:01:24 2007 +0200
Add sample images
diff --git a/src/samples/arc.png b/src/samples/arc.png
new file mode 100644
index 0000000..faa7a62
Binary files /dev/null and b/src/samples/arc.png differ
diff --git a/src/samples/arc_negative.png b/src/samples/arc_negative.png
new file mode 100644
index 0000000..396a9f8
Binary files /dev/null and b/src/samples/arc_negative.png differ
diff --git a/src/samples/clip.png b/src/samples/clip.png
new file mode 100644
index 0000000..6968c1e
Binary files /dev/null and b/src/samples/clip.png differ
diff --git a/src/samples/clip_image.png b/src/samples/clip_image.png
new file mode 100644
index 0000000..4a4febc
Binary files /dev/null and b/src/samples/clip_image.png differ
diff --git a/src/samples/curve_rectangle.png b/src/samples/curve_rectangle.png
new file mode 100644
index 0000000..89587bb
Binary files /dev/null and b/src/samples/curve_rectangle.png differ
diff --git a/src/samples/curve_to.png b/src/samples/curve_to.png
new file mode 100644
index 0000000..81b5a2d
Binary files /dev/null and b/src/samples/curve_to.png differ
diff --git a/src/samples/dash.png b/src/samples/dash.png
new file mode 100644
index 0000000..24c133c
Binary files /dev/null and b/src/samples/dash.png differ
diff --git a/src/samples/fill_and_stroke2.png b/src/samples/fill_and_stroke2.png
new file mode 100644
index 0000000..ee188b4
Binary files /dev/null and b/src/samples/fill_and_stroke2.png differ
diff --git a/src/samples/gradient.png b/src/samples/gradient.png
new file mode 100644
index 0000000..cf442c1
Binary files /dev/null and b/src/samples/gradient.png differ
diff --git a/src/samples/image.png b/src/samples/image.png
new file mode 100644
index 0000000..8132e21
Binary files /dev/null and b/src/samples/image.png differ
diff --git a/src/samples/imagepattern.png b/src/samples/imagepattern.png
new file mode 100644
index 0000000..eadaaf8
Binary files /dev/null and b/src/samples/imagepattern.png differ
diff --git a/src/samples/multi_segment_caps.png b/src/samples/multi_segment_caps.png
new file mode 100644
index 0000000..6b1a07e
Binary files /dev/null and b/src/samples/multi_segment_caps.png differ
diff --git a/src/samples/set_line_cap.png b/src/samples/set_line_cap.png
new file mode 100644
index 0000000..37eb2fe
Binary files /dev/null and b/src/samples/set_line_cap.png differ
diff --git a/src/samples/set_line_join.png b/src/samples/set_line_join.png
new file mode 100644
index 0000000..4250923
Binary files /dev/null and b/src/samples/set_line_join.png differ
diff --git a/src/samples/text.png b/src/samples/text.png
new file mode 100644
index 0000000..1798e3e
Binary files /dev/null and b/src/samples/text.png differ
diff --git a/src/samples/text_align_center.png b/src/samples/text_align_center.png
new file mode 100644
index 0000000..0373208
Binary files /dev/null and b/src/samples/text_align_center.png differ
diff --git a/src/samples/text_extents.png b/src/samples/text_extents.png
new file mode 100644
index 0000000..f29ce22
Binary files /dev/null and b/src/samples/text_extents.png differ
commit 82ef1f3c62507ee9711035e0c3adf11bf9b8efad
Author: Nis Martensen <nis.martensen at web.de>
Date: Fri Aug 3 17:59:25 2007 +0200
Add samples index page and samples inline template
diff --git a/src/samples.mdwn b/src/samples.mdwn
new file mode 100644
index 0000000..00def65
--- /dev/null
+++ b/src/samples.mdwn
@@ -0,0 +1,23 @@
+[[meta title="Cairo samples"]]
+
+This page contains samples of cairo's rendered output and the code
+snippets used to create them. The snippets are meant to be short, and
+easy to understand.
+
+[`cairo_snippets`][38], part of the cairo-demo module in cairo CVS, is
+used to create these webpages. `cairo_snippets` serves as a testbed for
+the rendered output of various cairo backends. The images rendered on
+these webpages are created by the `cairo_snippets_png` program, which is
+using cairo's software image backend.
+
+The snippet environment, and the original snippets were originally created
+by Øyvind Kolås for a paper submitted to [GUADEC 2004][39].
+
+All of his original snippet code is considered to be part of the public
+domain.
+
+[[inline pages="samples/* and !samples/*.png" show="0" template="cairo_sample" sort="title"]]
+
+ [1]: http://cairographics.org/
+ [38]: http://cvs.cairographics.org/cairo-demo/cairo_snippets/
+ [39]: http://2004.guadec.org/
diff --git a/templates/cairo_sample.tmpl b/templates/cairo_sample.tmpl
new file mode 100644
index 0000000..baf6397
--- /dev/null
+++ b/templates/cairo_sample.tmpl
@@ -0,0 +1,35 @@
+<TMPL_IF NAME="AUTHOR">
+<TMPL_IF NAME="AUTHORURL">
+<span class="author"><a href="<TMPL_VAR NAME=AUTHORURL>"><TMPL_VAR NAME=AUTHOR></a></span>
+<TMPL_ELSE>
+<span class="author"><TMPL_VAR NAME=AUTHOR></span>
+</TMPL_IF>
+</TMPL_IF>
+<TMPL_IF NAME="PERMALINK">
+<span class="header"><a href="<TMPL_VAR PERMALINK>"><TMPL_VAR TITLE></a></span>
+<TMPL_ELSE>
+<span class="header"><a href="<TMPL_VAR PAGEURL>"><TMPL_VAR TITLE></a></span>
+</TMPL_IF>
+<TMPL_VAR CONTENT>
+
+<TMPL_IF NAME="TAGS">
+<span class="tags">
+Tags:
+<TMPL_LOOP NAME="TAGS">
+<TMPL_VAR NAME=LINK>
+</TMPL_LOOP>
+</span>
+</TMPL_IF>
+
+<TMPL_IF NAME="HAVE_ACTIONS">
+<div class="actions">
+<ul>
+<TMPL_IF NAME="EDITURL">
+<li><a href="<TMPL_VAR EDITURL>">Edit</a></li>
+</TMPL_IF>
+<TMPL_IF NAME="DISCUSSIONLINK">
+<li><TMPL_VAR DISCUSSIONLINK></li>
+</TMPL_IF>
+</ul>
+</div>
+</TMPL_IF>
commit 413558a3b76f9a365af5521023c16efec4f35b83
Author: Carl Worth <cworth at cworth.org>
Date: Fri Aug 3 10:39:05 2007 -0700
Use space instead of comma to separate transforms
Otherwise, librsvg (at least) gets really confused
diff --git a/src/cairo-banner.svg b/src/cairo-banner.svg
index a1d993c..13b91c3 100644
--- a/src/cairo-banner.svg
+++ b/src/cairo-banner.svg
@@ -177,7 +177,7 @@
</g>
</g>
- <use xlink:href="#scarab" transform="translate(0,47),scale(.2)" />
+ <use xlink:href="#scarab" transform="translate(0,47) scale(.2)" />
</g>
@@ -185,6 +185,6 @@
<use xlink:href="#scarab_and_dung" transform="translate(30.5,0)" />
<use xlink:href="#cairo_text_small" transform="translate(185, 86)" fill="#162284" />
- <use xlink:href="#scarab_and_dung" transform="translate(339.5,0),scale(-1,1)" />
+ <use xlink:href="#scarab_and_dung" transform="translate(339.5,0) scale(-1,1)" />
</svg>
More information about the cairo-commit
mailing list