summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2006-01-26 15:59:15 +0000
committerMurray Cumming <murrayc@murrayc.com>2006-01-26 15:59:15 +0000
commit56dd0a259ca3e51ad0b439d702fe25643117f0cb (patch)
tree1a066bf2177757d182d82cc6709ca5db5d5254a2
parent6f5aec1bf7fd4abbf75ae990b4b9775187f3c786 (diff)
2006-01-25 Jonathon Jongsma <jonathon.jongsma@gmail.com>
* configure.in: * examples/Makefile.am: * examples/pdf-surface/: * examples/ps-surface/: * examples/svg-surface/: add examples for additional surfaces
-rw-r--r--ChangeLog8
-rw-r--r--configure.in3
-rw-r--r--examples/Makefile.am2
-rw-r--r--examples/pdf-surface/Makefile.am8
-rw-r--r--examples/pdf-surface/main.cc53
-rw-r--r--examples/ps-surface/Makefile.am7
-rw-r--r--examples/ps-surface/main.cc53
-rw-r--r--examples/svg-surface/Makefile.am7
-rw-r--r--examples/svg-surface/main.cc53
9 files changed, 193 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c6a58c4..eee4d7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-01-25 Jonathon Jongsma <jonathon.jongsma@gmail.com>
+
+ * configure.in:
+ * examples/Makefile.am:
+ * examples/pdf-surface/:
+ * examples/ps-surface/:
+ * examples/svg-surface/: add examples for additional surfaces
+
2006-01-24 Murray Cumming <murrayc@murrayc.com>
* cairomm/Makefile.am:
diff --git a/configure.in b/configure.in
index f8eec77..4094ce2 100644
--- a/configure.in
+++ b/configure.in
@@ -100,6 +100,9 @@ AC_OUTPUT(
examples/Makefile
examples/png_file/Makefile
+ examples/pdf-surface/Makefile
+ examples/ps-surface/Makefile
+ examples/svg-surface/Makefile
cairomm-1.0.pc
)
diff --git a/examples/Makefile.am b/examples/Makefile.am
index f2fabdf..373c1ed 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = png_file
+SUBDIRS = png_file pdf-surface ps-surface svg-surface
EXTRA_DIST = README Makefile.am_fragment
diff --git a/examples/pdf-surface/Makefile.am b/examples/pdf-surface/Makefile.am
new file mode 100644
index 0000000..2c13727
--- /dev/null
+++ b/examples/pdf-surface/Makefile.am
@@ -0,0 +1,8 @@
+include $(top_srcdir)/examples/Makefile.am_fragment
+
+# build the executable but don't install it
+example_pdf_file_LDADD = $(top_srcdir)/cairomm/libcairomm-1.0.la
+noinst_PROGRAMS = example_pdf_file
+example_pdf_file_SOURCES = main.cc
+
+CLEANFILES = image.pdf
diff --git a/examples/pdf-surface/main.cc b/examples/pdf-surface/main.cc
new file mode 100644
index 0000000..7a7f887
--- /dev/null
+++ b/examples/pdf-surface/main.cc
@@ -0,0 +1,53 @@
+#include <string>
+#include <iostream>
+#include <cairomm/context.h>
+#include <cairomm/surface.h>
+
+int main(int argc, char** argv)
+{
+#ifdef CAIRO_HAS_PDF_SURFACE
+
+ std::string filename = "image.pdf";
+ int width = 600;
+ int height = 400;
+ Cairo::RefPtr<Cairo::PdfSurface> surface =
+ Cairo::PdfSurface::create(filename, width, height);
+
+ Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
+
+ cr->save(); // save the state of the context
+ cr->set_source_rgb(0.86, 0.85, 0.47);
+ cr->paint(); // fill image with the color
+ cr->restore(); // color is back to black now
+
+ cr->save();
+ // draw a border around the image
+ cr->set_line_width(20.0); // make the line wider
+ cr->rectangle(0.0, 0.0, cairo_image_surface_get_width(surface->cobj()), height);
+ cr->stroke();
+
+ cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
+ // draw a circle in the center of the image
+ cr->arc(width / 2.0, height / 2.0,
+ height / 4.0, 0.0, 2.0 * M_PI);
+ cr->stroke();
+
+ // draw a diagonal line
+ cr->move_to(width / 4.0, height / 4.0);
+ cr->line_to(width * 3.0 / 4.0, height * 3.0 / 4.0);
+ cr->stroke();
+ cr->restore();
+
+ cr->show_page();
+
+ std::cout << "Wrote PDF file \"" << filename << "\"" << std::endl;
+ return 0;
+
+#else
+
+ std::cout << "You must compile cairo with PDF support for this example to work."
+ << std::endl;
+ return 1;
+
+#endif
+}
diff --git a/examples/ps-surface/Makefile.am b/examples/ps-surface/Makefile.am
new file mode 100644
index 0000000..91df429
--- /dev/null
+++ b/examples/ps-surface/Makefile.am
@@ -0,0 +1,7 @@
+include $(top_srcdir)/examples/Makefile.am_fragment
+
+# build the executable but don't install it
+noinst_PROGRAMS = example_ps_file
+example_ps_file_SOURCES = main.cc
+
+CLEANFILES = image.ps
diff --git a/examples/ps-surface/main.cc b/examples/ps-surface/main.cc
new file mode 100644
index 0000000..5b2f35f
--- /dev/null
+++ b/examples/ps-surface/main.cc
@@ -0,0 +1,53 @@
+#include <string>
+#include <iostream>
+#include <cairomm/context.h>
+#include <cairomm/surface.h>
+
+int main(int argc, char** argv)
+{
+#ifdef CAIRO_HAS_PS_SURFACE
+
+ std::string filename = "image.ps";
+ double width = 600;
+ double height = 400;
+ Cairo::RefPtr<Cairo::PsSurface> surface =
+ Cairo::PsSurface::create(filename, width, height);
+
+ Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
+
+ cr->save(); // save the state of the context
+ cr->set_source_rgb(0.86, 0.85, 0.47);
+ cr->paint(); // fill image with the color
+ cr->restore(); // color is back to black now
+
+ cr->save();
+ // draw a border around the image
+ cr->set_line_width(20.0); // make the line wider
+ cr->rectangle(0.0, 0.0, cairo_image_surface_get_width(surface->cobj()), height);
+ cr->stroke();
+
+ cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
+ // draw a circle in the center of the image
+ cr->arc(width / 2.0, height / 2.0,
+ height / 4.0, 0.0, 2.0 * M_PI);
+ cr->stroke();
+
+ // draw a diagonal line
+ cr->move_to(width / 4.0, height / 4.0);
+ cr->line_to(width * 3.0 / 4.0, height * 3.0 / 4.0);
+ cr->stroke();
+ cr->restore();
+
+ cr->show_page();
+
+ std::cout << "Wrote PostScript file \"" << filename << "\"" << std::endl;
+ return 0;
+
+#else
+
+ std::cout << "You must compile cairo with PDF support for this example to work."
+ << std::endl;
+ return 1;
+
+#endif
+}
diff --git a/examples/svg-surface/Makefile.am b/examples/svg-surface/Makefile.am
new file mode 100644
index 0000000..cf8e094
--- /dev/null
+++ b/examples/svg-surface/Makefile.am
@@ -0,0 +1,7 @@
+include $(top_srcdir)/examples/Makefile.am_fragment
+
+# build the executable but don't install it
+noinst_PROGRAMS = example_svg_file
+example_svg_file_SOURCES = main.cc
+
+CLEANFILES = image.svg
diff --git a/examples/svg-surface/main.cc b/examples/svg-surface/main.cc
new file mode 100644
index 0000000..e63d7ad
--- /dev/null
+++ b/examples/svg-surface/main.cc
@@ -0,0 +1,53 @@
+#include <string>
+#include <iostream>
+#include <cairomm/context.h>
+#include <cairomm/surface.h>
+
+int main(int argc, char** argv)
+{
+#ifdef CAIRO_HAS_SVG_SURFACE
+
+ std::string filename = "image.svg";
+ double width = 600;
+ double height = 400;
+ Cairo::RefPtr<Cairo::SvgSurface> surface =
+ Cairo::SvgSurface::create(filename, width, height);
+
+ Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
+
+ cr->save(); // save the state of the context
+ cr->set_source_rgb(0.86, 0.85, 0.47);
+ cr->paint(); // fill image with the color
+ cr->restore(); // color is back to black now
+
+ cr->save();
+ // draw a border around the image
+ cr->set_line_width(20.0); // make the line wider
+ cr->rectangle(0.0, 0.0, cairo_image_surface_get_width(surface->cobj()), height);
+ cr->stroke();
+
+ cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
+ // draw a circle in the center of the image
+ cr->arc(width / 2.0, height / 2.0,
+ height / 4.0, 0.0, 2.0 * M_PI);
+ cr->stroke();
+
+ // draw a diagonal line
+ cr->move_to(width / 4.0, height / 4.0);
+ cr->line_to(width * 3.0 / 4.0, height * 3.0 / 4.0);
+ cr->stroke();
+ cr->restore();
+
+ cr->show_page();
+
+ std::cout << "Wrote PostScript file \"" << filename << "\"" << std::endl;
+ return 0;
+
+#else
+
+ std::cout << "You must compile cairo with PDF support for this example to work."
+ << std::endl;
+ return 1;
+
+#endif
+}