X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=examples%2Fsvgtiny_display_x11.c;h=ca746402fc0c57b7dc5f4654cabe69d5254530b0;hb=864636d1ee1bfabe716d46697b097d577ba226f8;hp=6758befb1ce8c9bf612c4f96f205c1f8a5265c16;hpb=088329388d215b3476bc3178e3cdc0ffbb0e951a;p=libsvgtiny.git diff --git a/examples/svgtiny_display_x11.c b/examples/svgtiny_display_x11.c index 6758bef..ca74640 100644 --- a/examples/svgtiny_display_x11.c +++ b/examples/svgtiny_display_x11.c @@ -13,9 +13,38 @@ * 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 + * */ @@ -32,7 +61,7 @@ #include #include #include -#include "svgtiny.h" +#include struct svgtiny_diagram *diagram; @@ -126,6 +155,9 @@ int main(int argc, char *argv[]) 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; @@ -342,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++) { @@ -350,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); @@ -417,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); }