static int svg_endpath(gx_device_vector *vdev, gx_path_type_t type) { gx_device_svg *svg = (gx_device_svg *)vdev; /* hack single-page output */ if (svg->page_count) return 0; /* skip non-drawing paths for now */ if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke)) return 0; dprintf("svg_endpath "); svg_print_path_type(svg, type); dprintf("\n"); /* close the path data attribute */ svg_write(svg, "'"); /* override the inherited stroke attribute if we're not stroking */ if (!(type & gx_path_type_stroke) && svg->strokecolor) svg_write(svg, " stroke='none'"); /* override the inherited fill attribute if we're not filling */ if (!(type & gx_path_type_fill) && svg->fillcolor) svg_write(svg, " fill='none'"); svg_write(svg, "/>\n"); return 0; }
static int svg_curveto(gx_device_vector *vdev, floatp x0, floatp y0, floatp x1, floatp y1, floatp x2, floatp y2, floatp x3, floatp y3, gx_path_type_t type) { gx_device_svg *svg = (gx_device_svg *)vdev; char line[SVG_LINESIZE]; /* hack single-page output */ if (svg->page_count) return 0; /* skip non-drawing paths for now */ if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke)) return 0; dprintf8("svg_curveto(%lf,%lf, %lf,%lf, %lf,%lf, %lf,%lf) ", x0,y0, x1,y1, x2,y2, x3,y3); svg_print_path_type(svg, type); dprintf("\n"); sprintf(line, " C%lf,%lf %lf,%lf %lf,%lf", x1,y1, x2,y2, x3,y3); svg_write(svg, line); return 0; }
static int svg_closepath(gx_device_vector *vdev, floatp x, floatp y, floatp x_start, floatp y_start, gx_path_type_t type) { gx_device_svg *svg = (gx_device_svg *)vdev; /* hack single-page output */ if (svg->page_count) return 0; /* skip non-drawing paths for now */ if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke)) return 0; dprintf("svg_closepath "); svg_print_path_type(svg, type); dprintf("\n"); svg_write(svg, " z"); return 0; }
static int svg_beginpath(gx_device_vector *vdev, gx_path_type_t type) { gx_device_svg *svg = (gx_device_svg *)vdev; /* hack single-page output */ if (svg->page_count) return 0; /* skip non-drawing paths for now */ if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke)) return 0; dprintf("svg_beginpath "); svg_print_path_type(svg, type); dprintf("\n"); svg_write_state(svg); svg_write(svg, "<path d='"); return 0; }
static int svg_dorect(gx_device_vector *vdev, fixed x0, fixed y0, fixed x1, fixed y1, gx_path_type_t type) { gx_device_svg *svg = (gx_device_svg *)vdev; char line[300]; /* hack single-page output */ if (svg->page_count) return 0; dprintf("svg_dorect "); svg_print_path_type(svg, type); dprintf("\n"); svg_write_state(svg); if (type & gx_path_type_clip) { svg_write(svg, "<clipPath>\n"); } sprintf(line, "<rect x='%lf' y='%lf' width='%lf' height='%lf'", fixed2float(x0), fixed2float(y0), fixed2float(x1 - x0), fixed2float(y1 - y0)); svg_write(svg, line); /* override the inherited stroke attribute if we're not stroking */ if (!(type & gx_path_type_stroke) && svg->strokecolor) svg_write(svg, " stroke='none'"); /* override the inherited fill attribute if we're not filling */ if (!(type & gx_path_type_fill) && svg->fillcolor) svg_write(svg, " fill='none'"); svg_write(svg, "/>\n"); if (type & gx_path_type_clip) { svg_write(svg, "</clipPath>\n"); } return 0; }
static int svg_lineto(gx_device_vector *vdev, floatp x0, floatp y0, floatp x, floatp y, gx_path_type_t type) { gx_device_svg *svg = (gx_device_svg *)vdev; char line[SVG_LINESIZE]; /* hack single-page output */ if (svg->page_count) return 0; /* skip non-drawing paths for now */ if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke)) return 0; if_debug4('_', "svg_lineto(%lf,%lf,%lf,%lf) ", x0,y0, x,y); svg_print_path_type(svg, type); if_debug0('_', "\n"); sprintf(line, " L%lf,%lf", x, y); svg_write(svg, line); return 0; }