]> gitweb.michael.orlitzky.com - libsvgtiny.git/blobdiff - examples/svgtiny_display_x11.c
examples/svgtiny_display_x11.c: update build instructions
[libsvgtiny.git] / examples / svgtiny_display_x11.c
index 291449d8c31eb1dcd78084ef66039f245e9918d8..ca746402fc0c57b7dc5f4654cabe69d5254530b0 100644 (file)
  *  main() - loads an SVG using svgtiny_create() and svgtiny_parse()
  *  event_diagram_expose() - renders the SVG by stepping through the shapes
  *
- * Compile using:
- *  gcc -g -W -Wall -o svgtiny_display_x11 svgtiny_display_x11.c \
- *          `pkg-config --cflags --libs libsvgtiny cairo` -lX11
+ * A GNUMakefile is provided to ease compilation. To build the example
+ * program against the system copy of libsvgtiny, you can simply run,
+ *
+ *   $ make
+ *
+ * Or, if you are developing libsvgtiny and want to build against your
+ * local copy, you can run,
+ *
+ *   $ CPPFLAGS="-I../include" make
+ *
+ * to ensure that your (local) copy of the headers are used. You will
+ * need to modify this further if libsvgtiny is not installed on the
+ * system where you're developing. In addition to the "-I" directive
+ * above, you'll need both
+ *
+ *   CPPFLAGS="-L/path/to/your/libsvgtiny/build/directory"
+ *   LIBS="-lsvgtiny"
+ *
+ * to tell your compiler to link against the local libsvgtiny and
+ * where to find it.
+ *
+ * Finally, when you want to _run_ the example program using your
+ * local copy of libsvgtiny (whether or not a system copy is
+ * installed), you'll need to set
+ *
+ *   LD_LIBRARY_PATH=/path/to/your/libsvgtiny/build/directory
+ *
+ * The shared-library build directory is platform-specific, but it
+ * should look something like,
+ *
+ *   build-x86_64-pc-linux-gnu-x86_64-pc-linux-gnu-release-lib-shared
+ *
  */
 
 
@@ -345,7 +374,7 @@ void event_diagram_expose(const XExposeEvent *expose_event)
                return;
        }
 
-       cairo_set_source_rgb(cr, 1, 1, 1);
+       cairo_set_source_rgba(cr, 1, 1, 1, 1);
        cairo_paint(cr);
 
        for (i = 0; i != diagram->shape_count; i++) {
@@ -353,10 +382,11 @@ void event_diagram_expose(const XExposeEvent *expose_event)
                        render_path(cr, scale, &diagram->shape[i]);
 
                } else if (diagram->shape[i].text) {
-                       cairo_set_source_rgb(cr,
+                       cairo_set_source_rgba(cr,
                                svgtiny_RED(diagram->shape[i].stroke) / 255.0,
                                svgtiny_GREEN(diagram->shape[i].stroke) / 255.0,
-                               svgtiny_BLUE(diagram->shape[i].stroke) / 255.0);
+                               svgtiny_BLUE(diagram->shape[i].stroke) / 255.0,
+                               diagram->shape[i].stroke_opacity);
                        cairo_move_to(cr,
                                        scale * diagram->shape[i].text_x,
                                        scale * diagram->shape[i].text_y);
@@ -420,17 +450,19 @@ void render_path(cairo_t *cr, float scale, struct svgtiny_shape *path)
                }
        }
        if (path->fill != svgtiny_TRANSPARENT) {
-               cairo_set_source_rgb(cr,
+               cairo_set_source_rgba(cr,
                                svgtiny_RED(path->fill) / 255.0,
                                svgtiny_GREEN(path->fill) / 255.0,
-                               svgtiny_BLUE(path->fill) / 255.0);
+                               svgtiny_BLUE(path->fill) / 255.0,
+                               path->fill_opacity);
                cairo_fill_preserve(cr);
        }
        if (path->stroke != svgtiny_TRANSPARENT) {
-               cairo_set_source_rgb(cr,
+               cairo_set_source_rgba(cr,
                                svgtiny_RED(path->stroke) / 255.0,
                                svgtiny_GREEN(path->stroke) / 255.0,
-                               svgtiny_BLUE(path->stroke) / 255.0);
+                               svgtiny_BLUE(path->stroke) / 255.0,
+                               path->stroke_opacity);
                cairo_set_line_width(cr, scale * path->stroke_width);
                cairo_stroke_preserve(cr);
        }