* 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
+ *
*/
#include <X11/keysym.h>
#include <cairo.h>
#include <cairo-xlib.h>
-#include "svgtiny.h"
+#include <svgtiny.h>
struct svgtiny_diagram *diagram;
diagram->error_line,
diagram->error_message);
break;
+ case svgtiny_LIBCSS_ERROR:
+ fprintf(stderr, "svgtiny_LIBCSS_ERROR");
+ break;
default:
fprintf(stderr, "unknown svgtiny_code %i", code);
break;
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++) {
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);
}
}
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);
}