1 /****************************************************************************
2 * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002
3 ****************************************************************************
4 * rrd_gfx.c graphics wrapper for rrdtool
5 **************************************************************************/
10 # define DPRINT(x) (void)(printf x, printf("\n"))
17 #include FT_FREETYPE_H
22 /* lines are better drawn on the pixle than between pixles */
23 #define LINEOFFSET 0.5
26 gfx_node_t *gfx_new_node( gfx_canvas_t *canvas,enum gfx_en type){
27 gfx_node_t *node = art_new(gfx_node_t,1);
28 if (node == NULL) return NULL;
30 node->color = 0x0; /* color of element 0xRRGGBBAA alpha 0xff is solid*/
31 node->size =0.0; /* font size, line width */
32 node->path = NULL; /* path */
35 node->closed_path = 0;
36 node->svp = NULL; /* svp */
37 node->filename = NULL; /* font or image filename */
40 node->y = 0.0; /* position */
42 node->halign = GFX_H_NULL; /* text alignement */
43 node->valign = GFX_V_NULL; /* text alignement */
46 if (canvas->lastnode != NULL){
47 canvas->lastnode->next = node;
49 if (canvas->firstnode == NULL){
50 canvas->firstnode = node;
52 canvas->lastnode = node;
56 gfx_canvas_t *gfx_new_canvas (void) {
57 gfx_canvas_t *canvas = art_new(gfx_canvas_t,1);
58 canvas->firstnode = NULL;
59 canvas->lastnode = NULL;
60 canvas->imgformat = IF_PNG; /* we default to PNG output */
61 canvas->interlaced = 0;
66 /* create a new line */
67 gfx_node_t *gfx_new_line(gfx_canvas_t *canvas,
70 double width, gfx_color_t color){
71 return gfx_new_dashed_line(canvas, x0, y0, x1, y1, width, color, 0, 0);
74 gfx_node_t *gfx_new_dashed_line(gfx_canvas_t *canvas,
77 double width, gfx_color_t color,
78 double dash_on, double dash_off){
82 node = gfx_new_node(canvas,GFX_LINE);
83 if (node == NULL) return NULL;
84 vec = art_new(ArtVpath, 3);
85 if (vec == NULL) return NULL;
86 vec[0].code = ART_MOVETO_OPEN; vec[0].x=x0+LINEOFFSET; vec[0].y=y0+LINEOFFSET;
87 vec[1].code = ART_LINETO; vec[1].x=x1+LINEOFFSET; vec[1].y=y1+LINEOFFSET;
88 vec[2].code = ART_END;
94 node->dash_on = dash_on;
95 node->dash_off = dash_off;
100 /* create a new area */
101 gfx_node_t *gfx_new_area (gfx_canvas_t *canvas,
102 double x0, double y0,
103 double x1, double y1,
104 double x2, double y2,
109 node = gfx_new_node(canvas,GFX_AREA);
110 if (node == NULL) return NULL;
111 vec = art_new(ArtVpath, 5);
112 if (vec == NULL) return NULL;
113 vec[0].code = ART_MOVETO; vec[0].x=x0; vec[0].y=y0;
114 vec[1].code = ART_LINETO; vec[1].x=x1; vec[1].y=y1;
115 vec[2].code = ART_LINETO; vec[2].x=x2; vec[2].y=y2;
116 vec[3].code = ART_LINETO; vec[3].x=x0; vec[3].y=y0;
117 vec[4].code = ART_END;
120 node->points_max = 5;
127 /* add a point to a line or to an area */
128 int gfx_add_point (gfx_node_t *node,
130 if (node == NULL) return 1;
131 if (node->type == GFX_AREA) {
132 double x0 = node->path[0].x;
133 double y0 = node->path[0].y;
135 art_vpath_add_point (&(node->path),
140 art_vpath_add_point (&(node->path),
145 art_vpath_add_point (&(node->path),
150 } else if (node->type == GFX_LINE) {
152 art_vpath_add_point (&(node->path),
156 x+LINEOFFSET,y+LINEOFFSET);
157 art_vpath_add_point (&(node->path),
164 /* can only add point to areas and lines */
170 void gfx_close_path (gfx_node_t *node) {
171 node->closed_path = 1;
174 /* create a text node */
175 gfx_node_t *gfx_new_text (gfx_canvas_t *canvas,
176 double x, double y, gfx_color_t color,
177 char* font, double size,
178 double tabwidth, double angle,
179 enum gfx_h_align_en h_align,
180 enum gfx_v_align_en v_align,
182 gfx_node_t *node = gfx_new_node(canvas,GFX_TEXT);
184 /* currently we only support 0 and 270 */
188 node->text = strdup(text);
190 node->filename = strdup(font);
195 node->tabwidth = tabwidth;
196 node->halign = h_align;
197 node->valign = v_align;
201 int gfx_render(gfx_canvas_t *canvas,
202 art_u32 width, art_u32 height,
203 gfx_color_t background, FILE *fp){
204 switch (canvas->imgformat) {
206 return gfx_render_png (canvas, width, height, background, fp);
208 return gfx_render_svg (canvas, width, height, background, fp);
214 double gfx_get_text_width ( gfx_canvas_t *canvas,
215 double start, char* font, double size,
216 double tabwidth, char* text){
217 switch (canvas->imgformat) {
219 return gfx_get_text_width_libart (canvas, start, font, size, tabwidth, text);
221 return size * strlen(text);
225 double gfx_get_text_width_libart ( gfx_canvas_t *canvas,
226 double start, char* font, double size,
227 double tabwidth, char* text){
231 FT_UInt glyph_index=0;
235 FT_Library library=NULL;
237 FT_Init_FreeType( &library );
238 error = FT_New_Face( library, font, 0, &face );
239 if ( error ) return -1;
240 error = FT_Set_Char_Size(face, size*64,size*64, 100,100);
241 if ( error ) return -1;
243 use_kerning = FT_HAS_KERNING(face);
246 previous = glyph_index;
247 glyph_index = FT_Get_Char_Index( face, *text);
249 if (use_kerning && previous && glyph_index){
251 FT_Get_Kerning( face, previous, glyph_index,
253 text_width += (double)delta.x / 64.0;
256 error = FT_Load_Glyph( face, glyph_index, 0 );
258 FT_Done_FreeType(library);
262 text_width -= (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
264 text_width += (double)slot->metrics.horiAdvance / 64.0;
266 text_width -= (double)slot->metrics.horiAdvance / 64.0; /* remove last step */
267 text_width += (double)slot->metrics.width / 64.0; /* add just char width */
268 text_width += (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
269 FT_Done_FreeType(library);
276 static int gfx_save_png (art_u8 *buffer, FILE *fp,
277 long width, long height, long bytes_per_pixel);
278 /* render grafics into png image */
279 int gfx_render_png (gfx_canvas_t *canvas,
280 art_u32 width, art_u32 height,
281 gfx_color_t background, FILE *fp){
285 gfx_node_t *node = canvas->firstnode;
286 art_u8 red = background >> 24, green = (background >> 16) & 0xff;
287 art_u8 blue = (background >> 8) & 0xff, alpha = ( background & 0xff );
288 unsigned long pys_width = width * canvas->zoom;
289 unsigned long pys_height = height * canvas->zoom;
290 const int bytes_per_pixel = 3;
291 unsigned long rowstride = pys_width*bytes_per_pixel; /* bytes per pixel */
292 art_u8 *buffer = art_new (art_u8, rowstride*pys_height);
293 art_rgb_run_alpha (buffer, red, green, blue, alpha, pys_width*pys_height);
294 FT_Init_FreeType( &library );
296 switch (node->type) {
302 if (node->closed_path) {
303 /* libart uses end==start for closed as indicator of closed path */
304 gfx_add_point(node, node->path[0].x, node->path[0].y);
305 node->closed_path = 0;
307 art_affine_scale(dst,canvas->zoom,canvas->zoom);
308 vec = art_vpath_affine_transform(node->path,dst);
309 if(node->type == GFX_LINE){
310 svp = art_svp_vpath_stroke ( vec, ART_PATH_STROKE_JOIN_ROUND,
311 ART_PATH_STROKE_CAP_ROUND,
312 node->size*canvas->zoom,1,1);
314 svp = art_svp_from_vpath ( vec );
317 art_rgb_svp_alpha (svp ,0,0, pys_width, pys_height,
318 node->color, buffer, rowstride, NULL);
324 float text_width=0.0, text_height = 0.0;
326 art_u8 fcolor[3],falpha;
330 FT_UInt glyph_index=0;
333 float pen_x = 0.0 , pen_y = 0.0;
337 fcolor[0] = node->color >> 24;
338 fcolor[1] = (node->color >> 16) & 0xff;
339 fcolor[2] = (node->color >> 8) & 0xff;
340 falpha = node->color & 0xff;
341 error = FT_New_Face( library,
342 (char *)node->filename,
346 use_kerning = FT_HAS_KERNING(face);
348 error = FT_Set_Char_Size(face, /* handle to face object */
349 (long)(node->size*64),
350 (long)(node->size*64),
351 (long)(100*canvas->zoom),
352 (long)(100*canvas->zoom));
354 pen_x = node->x * canvas->zoom;
355 pen_y = node->y * canvas->zoom;
358 for(text=(unsigned char *)node->text;*text;text++) {
359 previous = glyph_index;
360 glyph_index = FT_Get_Char_Index( face, *text);
362 if (use_kerning && previous && glyph_index){
364 FT_Get_Kerning( face, previous, glyph_index,
366 text_width += (double)delta.x / 64.0;
369 error = FT_Load_Glyph( face, glyph_index, 0 );
372 pen_x -= (double)slot->metrics.horiBearingX / 64.0; /* adjust pos for first char */
373 text_width -= (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
375 if ( text_height < (double)slot->metrics.horiBearingY / 64.0 ) {
376 text_height = (double)slot->metrics.horiBearingY / 64.0;
378 text_width += (double)slot->metrics.horiAdvance / 64.0;
380 text_width -= (double)slot->metrics.horiAdvance / 64.0; /* remove last step */
381 text_width += (double)slot->metrics.width / 64.0; /* add just char width */
382 text_width += (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
384 switch(node->halign){
385 case GFX_H_RIGHT: pen_x -= text_width; break;
386 case GFX_H_CENTER: pen_x -= text_width / 2.0; break;
387 case GFX_H_LEFT: break;
390 switch(node->valign){
391 case GFX_V_TOP: pen_y += text_height; break;
392 case GFX_V_CENTER: pen_y += text_height / 2.0; break;
393 case GFX_V_BOTTOM: break;
397 for(text=(unsigned char *)node->text;*text;text++) {
399 previous = glyph_index;
400 glyph_index = FT_Get_Char_Index( face, *text);
402 if (use_kerning && previous && glyph_index){
404 FT_Get_Kerning( face, previous, glyph_index,
406 pen_x += (double)delta.x / 64.0;
409 error = FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER );
411 gr = slot->bitmap.num_grays -1;
412 for (iy=0; iy < slot->bitmap.rows; iy++){
413 long buf_y = iy+(pen_y+0.5)-slot->bitmap_top;
414 if (buf_y < 0 || buf_y >= pys_height) continue;
416 for (ix=0;ix < slot->bitmap.width;ix++){
417 long buf_x = ix + (pen_x + 0.5) + (double)slot->bitmap_left ;
420 if (buf_x < 0 || buf_x >= pys_width) continue;
421 buf_x *= bytes_per_pixel ;
422 font_alpha = *(slot->bitmap.buffer + iy * slot->bitmap.width + ix);
423 font_alpha = (art_u8)((double)font_alpha / gr * falpha);
424 for (iz = 0; iz < 3; iz++){
425 art_u8 *orig = buffer + buf_y + buf_x + iz;
426 *orig = (art_u8)((double)*orig / gr * ( gr - font_alpha) +
427 (double)fcolor[iz] / gr * (font_alpha));
431 pen_x += (double)slot->metrics.horiAdvance / 64.0;
437 gfx_save_png(buffer,fp , pys_width,pys_height,bytes_per_pixel);
439 FT_Done_FreeType( library );
443 /* free memory used by nodes this will also remove memory required for
444 associated paths and svcs ... but not for text strings */
446 gfx_destroy (gfx_canvas_t *canvas){
447 gfx_node_t *next,*node = canvas->firstnode;
450 art_free(node->path);
453 free(node->filename);
460 static int gfx_save_png (art_u8 *buffer, FILE *fp, long width, long height, long bytes_per_pixel){
461 png_structp png_ptr = NULL;
462 png_infop info_ptr = NULL;
464 png_bytep *row_pointers;
465 int rowstride = width * bytes_per_pixel;
471 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
476 row_pointers = (png_bytepp)png_malloc(png_ptr,
477 height*sizeof(png_bytep));
479 info_ptr = png_create_info_struct(png_ptr);
481 if (info_ptr == NULL)
483 png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
487 if (setjmp(png_jmpbuf(png_ptr)))
489 /* If we get here, we had a problem writing the file */
490 png_destroy_write_struct(&png_ptr, &info_ptr);
494 png_init_io(png_ptr, fp);
495 png_set_IHDR (png_ptr, info_ptr,width, height,
496 8, PNG_COLOR_TYPE_RGB,
498 PNG_COMPRESSION_TYPE_DEFAULT,
499 PNG_FILTER_TYPE_DEFAULT);
501 text[0].key = "Software";
502 text[0].text = "RRDtool, Tobias Oetiker <tobi@oetike.ch>, http://tobi.oetiker.ch";
503 text[0].compression = PNG_TEXT_COMPRESSION_NONE;
504 png_set_text (png_ptr, info_ptr, text, 1);
506 /* Write header data */
507 png_write_info (png_ptr, info_ptr);
509 for (i = 0; i < height; i++)
510 row_pointers[i] = (png_bytep) (buffer + i*rowstride);
512 png_write_image(png_ptr, row_pointers);
513 png_write_end(png_ptr, info_ptr);
514 png_destroy_write_struct(&png_ptr, &info_ptr);
519 /* ------- SVG -------
521 http://www.w3.org/TR/SVG/
523 static int svg_indent = 0;
524 static int svg_single_line = 0;
525 static const char *svg_default_font = "Helvetica";
527 static void svg_print_indent(FILE *fp)
530 for (i = svg_indent - svg_single_line; i > 0; i--) {
536 static void svg_start_tag(FILE *fp, const char *name)
538 svg_print_indent(fp);
544 static void svg_close_tag_single_line(FILE *fp)
550 static void svg_close_tag(FILE *fp)
553 if (!svg_single_line)
557 static void svg_end_tag(FILE *fp, const char *name)
559 /* name is NULL if closing empty-node tag */
564 svg_print_indent(fp);
574 static void svg_close_tag_empty_node(FILE *fp)
576 svg_end_tag(fp, NULL);
579 static void svg_write_text(FILE *fp, const char *p)
582 const char *start, *last;
585 /* trim leading spaces */
589 /* trim trailing spaces */
591 while ((ch = *p) != 0) {
596 /* encode trimmed text */
601 case '&': fputs("&", fp); break;
602 case '<': fputs("<", fp); break;
603 case '>': fputs(">", fp); break;
604 case '"': fputs(""", fp); break;
605 default: putc(ch, fp);
610 static void svg_write_number(FILE *fp, double d)
612 /* omit decimals if integer to reduce filesize */
614 snprintf(buf, sizeof(buf), "%.2f", d);
615 p = buf; /* doesn't trust snprintf return value */
621 *p = '\0'; /* zap trailing zeros */
625 *p = '\0'; /* zap trailing dot */
631 static int svg_color_is_black(int c)
633 /* gfx_color_t is RRGGBBAA */
634 return c == 0x000000FF;
637 static void svg_write_color(FILE *fp, gfx_color_t c, const char *attr)
639 /* gfx_color_t is RRGGBBAA, svg can use #RRGGBB and #RGB like html */
640 gfx_color_t rrggbb = (int)((c >> 8) & 0xFFFFFF);
641 gfx_color_t opacity = c & 0xFF;
642 fprintf(fp, " %s=\"", attr);
643 if ((rrggbb & 0x0F0F0F) == ((rrggbb >> 4) & 0x0F0F0F)) {
644 /* css2 short form, #rgb is #rrggbb, not #r0g0b0 */
645 fprintf(fp, "#%03lX",
646 ( ((rrggbb >> 8) & 0xF00)
647 | ((rrggbb >> 4) & 0x0F0)
648 | ( rrggbb & 0x00F)));
650 fprintf(fp, "#%06lX", rrggbb);
653 if (opacity != 0xFF) {
654 fprintf(fp, " stroke-opacity=\"");
655 svg_write_number(fp, opacity / 255.0);
660 static void svg_common_path_attributes(FILE *fp, gfx_node_t *node)
662 fputs(" stroke-width=\"", fp);
663 svg_write_number(fp, node->size);
665 svg_write_color(fp, node->color, "stroke");
666 fputs(" fill=\"none\"", fp);
667 if (node->dash_on != 0 && node->dash_off != 0) {
668 fputs(" stroke-dasharray=\"", fp);
669 svg_write_number(fp, node->dash_on);
671 svg_write_number(fp, node->dash_off);
676 static int svg_is_int_step(double a, double b)
678 double diff = fabs(a - b);
679 return floor(diff) == diff;
682 static int svg_path_straight_segment(FILE *fp,
683 double lastA, double currentA, double currentB,
685 int segment_idx, int isx, char absChar, char relChar)
687 if (!svg_is_int_step(lastA, currentA)) {
689 svg_write_number(fp, currentA);
692 if (segment_idx < node->points - 1) {
693 ArtVpath *vec = node->path + segment_idx + 1;
694 if (vec->code == ART_LINETO) {
695 double nextA = (isx ? vec->x : vec->y) - LINEOFFSET;
696 double nextB = (isx ? vec->y : vec->x) - LINEOFFSET;
697 if (nextB == currentB
698 && ((currentA >= lastA) == (nextA >= currentA))
699 && svg_is_int_step(currentA, nextA)) {
700 return 1; /* skip to next as it is a straight line */
705 svg_write_number(fp, currentA - lastA);
709 static void svg_path(FILE *fp, gfx_node_t *node, int multi)
712 double lastX = 0, lastY = 0;
713 /* for straight lines <path..> tags take less space than
714 <line..> tags because of the efficient packing
715 in the 'd' attribute */
716 svg_start_tag(fp, "path");
718 svg_common_path_attributes(fp, node);
720 /* specification of the 'd' attribute: */
721 /* http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation */
722 for (i = 0; i < node->points; i++) {
723 ArtVpath *vec = node->path + i;
724 double x = vec->x - LINEOFFSET;
725 double y = vec->y - LINEOFFSET;
727 case ART_MOVETO_OPEN: /* fall-through */
730 svg_write_number(fp, x);
732 svg_write_number(fp, y);
735 /* try optimize filesize by using minimal lineto commands */
736 /* without introducing rounding errors. */
738 if (svg_path_straight_segment(fp, lastY, y, x, node, i, 0, 'V', 'v'))
740 } else if (y == lastY) {
741 if (svg_path_straight_segment(fp, lastX, x, y, node, i, 1, 'H', 'h'))
745 svg_write_number(fp, x);
747 svg_write_number(fp, y);
750 case ART_CURVETO: break; /* unsupported */
751 case ART_END: break; /* nop */
756 if (node->closed_path)
759 svg_close_tag_empty_node(fp);
762 static void svg_multi_path(FILE *fp, gfx_node_t **nodeR)
764 /* optimize for multiple paths with the same color, penwidth, etc. */
766 gfx_node_t *node = *nodeR;
767 gfx_node_t *next = node->next;
769 if (next->type != node->type
770 || next->size != node->size
771 || next->color != node->color
772 || next->dash_on != node->dash_on
773 || next->dash_off != node->dash_off)
779 svg_path(fp, node, 0);
782 svg_start_tag(fp, "g");
783 svg_common_path_attributes(fp, node);
785 while (num && node) {
786 svg_path(fp, node, 1);
792 svg_end_tag(fp, "g");
795 static void svg_area(FILE *fp, gfx_node_t *node)
798 double startX = 0, startY = 0;
799 svg_start_tag(fp, "polygon");
801 svg_write_color(fp, node->color, "fill");
802 fputs(" points=\"", fp);
803 for (i = 0; i < node->points; i++) {
804 ArtVpath *vec = node->path + i;
805 double x = vec->x - LINEOFFSET;
806 double y = vec->y - LINEOFFSET;
808 case ART_MOVETO_OPEN: /* fall-through */
810 svg_write_number(fp, x);
812 svg_write_number(fp, y);
817 if (i == node->points - 2
818 && node->path[i + 1].code == ART_END
819 && fabs(x - startX) < 0.001 && fabs(y - startY) < 0.001) {
820 break; /* poly area always closed, no need for last point */
823 svg_write_number(fp, x);
825 svg_write_number(fp, y);
827 case ART_CURVETO: break; /* unsupported */
828 case ART_END: break; /* nop */
832 svg_close_tag_empty_node(fp);
835 static void svg_text(FILE *fp, gfx_node_t *node)
837 double x = node->x - LINEOFFSET;
838 double y = node->y - LINEOFFSET;
839 if (node->angle != 0) {
840 svg_start_tag(fp, "g");
841 fputs(" transform=\"translate(", fp);
842 svg_write_number(fp, x);
844 svg_write_number(fp, y);
845 fputs(") rotate(", fp);
846 svg_write_number(fp, node->angle);
851 switch (node->valign) {
852 case GFX_V_TOP: y += node->size; break;
853 case GFX_V_CENTER: y += node->size / 2; break;
854 case GFX_V_BOTTOM: break;
855 case GFX_V_NULL: break;
857 svg_start_tag(fp, "text");
859 svg_write_number(fp, x);
860 fputs("\" y=\"", fp);
861 svg_write_number(fp, y);
862 if (strcmp(node->filename, svg_default_font))
863 fprintf(fp, " font-family=\"%s\"", node->filename);
864 fputs("\" font-size=\"", fp);
865 svg_write_number(fp, node->size);
867 if (!svg_color_is_black(node->color))
868 svg_write_color(fp, node->color, "fill");
869 switch (node->halign) {
870 case GFX_H_RIGHT: fputs(" text-anchor=\"end\"", fp); break;
871 case GFX_H_CENTER: fputs(" text-anchor=\"middle\"", fp); break;
872 case GFX_H_LEFT: break;
873 case GFX_H_NULL: break;
875 svg_close_tag_single_line(fp);
876 /* support for node->tabwidth missing */
877 svg_write_text(fp, node->text);
878 svg_end_tag(fp, "text");
879 if (node->angle != 0)
880 svg_end_tag(fp, "g");
883 int gfx_render_svg (gfx_canvas_t *canvas,
884 art_u32 width, art_u32 height,
885 gfx_color_t background, FILE *fp){
886 gfx_node_t *node = canvas->firstnode;
888 "<?xml version=\"1.0\" standalone=\"no\"?>\n"
889 "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\"\n"
890 " \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
892 " SVG file created by RRDtool,\n"
893 " Tobias Oetiker <tobi@oetike.ch>, http://tobi.oetiker.ch\n"
895 " The width/height attributes in the outhermost svg node\n"
896 " are just default sizes for the browser which is used\n"
897 " if the svg file is openened directly without being\n"
898 " embedded in an html file.\n"
899 " The viewBox is the local coord system for rrdtool.\n"
901 svg_start_tag(fp, "svg");
902 fputs(" width=\"", fp);
903 svg_write_number(fp, width * canvas->zoom);
904 fputs("\" height=\"", fp);
905 svg_write_number(fp, height * canvas->zoom);
906 fputs("\" x=\"0\" y=\"0\" viewBox=\"", fp);
907 svg_write_number(fp, -LINEOFFSET);
909 svg_write_number(fp, -LINEOFFSET);
911 svg_write_number(fp, width - LINEOFFSET);
913 svg_write_number(fp, height - LINEOFFSET);
914 fputs("\" preserveAspectRatio=\"xMidYMid\"", fp);
915 fprintf(fp, " font-family=\"%s\"", svg_default_font); /* default font */
916 fputs(" stroke-linecap=\"round\" stroke-linejoin=\"round\"", fp);
918 svg_start_tag(fp, "rect");
919 fprintf(fp, " x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", width, height);
920 svg_write_color(fp, background, "fill");
921 svg_close_tag_empty_node(fp);
923 switch (node->type) {
925 svg_multi_path(fp, &node);
935 svg_end_tag(fp, "svg");